<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	
	>
<channel>
	<title>
	Comments on: Symfony, Propel und SQL Aggregate Functions	</title>
	<atom:link href="https://nerdpress.org/2009/09/08/symfony-propel-und-sql-aggregate-functions/feed/" rel="self" type="application/rss+xml" />
	<link>https://nerdpress.org/2009/09/08/symfony-propel-und-sql-aggregate-functions/</link>
	<description>...dev, tech problems and solutions.</description>
	<lastBuildDate>Wed, 09 Sep 2009 09:10:55 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>
		By: Johannes Heinen		</title>
		<link>https://nerdpress.org/2009/09/08/symfony-propel-und-sql-aggregate-functions/#comment-22</link>

		<dc:creator><![CDATA[Johannes Heinen]]></dc:creator>
		<pubDate>Wed, 09 Sep 2009 09:10:55 +0000</pubDate>
		<guid isPermaLink="false">https://nerdpress.org/?p=148#comment-22</guid>

					<description><![CDATA[Zufall! Ich hatte exakt das gleiche Problem und habe auch mit dem Gedanken gespielt, dazu was zu schreiben und mein Leid zu klagen. In dem Falle ging es um eine simple Aggregatfunktion (LEFT JOIN, dann count(Pk) über eine Rating-(Ziel-)Tabelle), dann nach Pk der Quelltabelle sortiert.

Also vereinfacht.
[sourcecode lang=&quot;SQL&quot;]
SELECT a.*, count(b.id) c rating FROM a
LEFT JOIN b ON b.a_id = a.id
GROUP BY a.id
ORDER BY c
[/sourcecode]

Natürlich fliegt einem populateObjects() aufgrund der veränderten Anzahl Attribute um die Ohren.

Die Lösung in dem Fall war einfach: count(b.id) aus dem SELECT Statement herausnehmen (also addAsColumn() entfernen) und in -&gt;addDescendingOrder(&#039;count(&#039;.bPeer::ID.&#039;)&#039;) hineinfummeln.

Wahrscheinlich ist es nur ein unglaublicher Zufall, dass das überhaupt funktioniert :D

Komplexe Custom Queries sind einfach nicht gut Freund mit Propel, was sich aber in der kürzlich angekündigten 1.4 bzw. PHP5.3-kompatiblen 2.0 Branch grundlegend ändern soll. Man wird sehen, was da kommt.]]></description>
			<content:encoded><![CDATA[<p>Zufall! Ich hatte exakt das gleiche Problem und habe auch mit dem Gedanken gespielt, dazu was zu schreiben und mein Leid zu klagen. In dem Falle ging es um eine simple Aggregatfunktion (LEFT JOIN, dann count(Pk) über eine Rating-(Ziel-)Tabelle), dann nach Pk der Quelltabelle sortiert.</p>
<p>Also vereinfacht.</p>
<pre class="brush: sql; title: ; notranslate">
SELECT a.*, count(b.id) c rating FROM a
LEFT JOIN b ON b.a_id = a.id
GROUP BY a.id
ORDER BY c
</pre>
<p>Natürlich fliegt einem populateObjects() aufgrund der veränderten Anzahl Attribute um die Ohren.</p>
<p>Die Lösung in dem Fall war einfach: count(b.id) aus dem SELECT Statement herausnehmen (also addAsColumn() entfernen) und in ->addDescendingOrder(&#8216;count(&#8216;.bPeer::ID.&#8217;)&#8217;) hineinfummeln.</p>
<p>Wahrscheinlich ist es nur ein unglaublicher Zufall, dass das überhaupt funktioniert :D</p>
<p>Komplexe Custom Queries sind einfach nicht gut Freund mit Propel, was sich aber in der kürzlich angekündigten 1.4 bzw. PHP5.3-kompatiblen 2.0 Branch grundlegend ändern soll. Man wird sehen, was da kommt.</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
