<?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: Propel Queries using Custom SQL, Peer Classes, and Criterion Objects</title>
	<atom:link href="http://stereointeractive.com/blog/2007/06/12/propel-queries-using-custom-sql-peer-classes-and-criterion-objects/feed/" rel="self" type="application/rss+xml" />
	<link>http://stereointeractive.com/blog/2007/06/12/propel-queries-using-custom-sql-peer-classes-and-criterion-objects/</link>
	<description>Development Blog</description>
	<lastBuildDate>Thu, 17 Jun 2010 09:37:20 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Scott Meves</title>
		<link>http://stereointeractive.com/blog/2007/06/12/propel-queries-using-custom-sql-peer-classes-and-criterion-objects/comment-page-1/#comment-544</link>
		<dc:creator>Scott Meves</dc:creator>
		<pubDate>Wed, 03 Mar 2010 08:00:16 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stereodevelopment.com/2007/06/12/propel-queries-using-custom-sql-peer-classes-and-criterion-objects/#comment-544</guid>
		<description>Hi Phuc, these functions only work with Symfony 1.0.</description>
		<content:encoded><![CDATA[<p>Hi Phuc, these functions only work with Symfony 1.0.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Phuc</title>
		<link>http://stereointeractive.com/blog/2007/06/12/propel-queries-using-custom-sql-peer-classes-and-criterion-objects/comment-page-1/#comment-543</link>
		<dc:creator>Phuc</dc:creator>
		<pubDate>Mon, 01 Mar 2010 07:56:54 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stereodevelopment.com/2007/06/12/propel-queries-using-custom-sql-peer-classes-and-criterion-objects/#comment-543</guid>
		<description>Hi,
Thank you for this acticle. But i have a problem when use propel sql like that :
$con = Propel::getConnection(DATABASE_NAME);
$sql = &quot;SELECT books.* FROM books 
    WHERE NOT EXISTS (SELECT id FROM review WHERE book_id = book.id)&quot;;
$stmt = $con-&gt;createStatement();
$rs = $stmt-&gt;executeQuery($sql, ResultSet::FETCHMODE_NUM);
$books = BookPeer::populateObjects($rs);
Result : Call to undefined method DebugPDO::createStatement() 
I use symfony 1.27 . 
And have error the same if i use prepareStatement();
Could you help me?</description>
		<content:encoded><![CDATA[<p>Hi,<br />
Thank you for this acticle. But i have a problem when use propel sql like that :<br />
$con = Propel::getConnection(DATABASE_NAME);<br />
$sql = &#8220;SELECT books.* FROM books<br />
    WHERE NOT EXISTS (SELECT id FROM review WHERE book_id = book.id)&#8221;;<br />
$stmt = $con-&gt;createStatement();<br />
$rs = $stmt-&gt;executeQuery($sql, ResultSet::FETCHMODE_NUM);<br />
$books = BookPeer::populateObjects($rs);<br />
Result : Call to undefined method DebugPDO::createStatement()<br />
I use symfony 1.27 .<br />
And have error the same if i use prepareStatement();<br />
Could you help me?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kamil</title>
		<link>http://stereointeractive.com/blog/2007/06/12/propel-queries-using-custom-sql-peer-classes-and-criterion-objects/comment-page-1/#comment-520</link>
		<dc:creator>Kamil</dc:creator>
		<pubDate>Wed, 06 Jan 2010 12:21:34 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stereodevelopment.com/2007/06/12/propel-queries-using-custom-sql-peer-classes-and-criterion-objects/#comment-520</guid>
		<description>Thank you, really usefull tips.
Cheers</description>
		<content:encoded><![CDATA[<p>Thank you, really usefull tips.<br />
Cheers</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Manel</title>
		<link>http://stereointeractive.com/blog/2007/06/12/propel-queries-using-custom-sql-peer-classes-and-criterion-objects/comment-page-1/#comment-422</link>
		<dc:creator>Manel</dc:creator>
		<pubDate>Fri, 05 Jun 2009 07:28:26 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stereodevelopment.com/2007/06/12/propel-queries-using-custom-sql-peer-classes-and-criterion-objects/#comment-422</guid>
		<description>Thanks!!! You have saved my day!!!

I need to order a query putting the null values of one field at the end.

I&#039;ve combined your tip with this: http://www.shawnolson.net/a/730/mysql-sort-order-with-null.html. I hope that this can help anyone.</description>
		<content:encoded><![CDATA[<p>Thanks!!! You have saved my day!!!</p>
<p>I need to order a query putting the null values of one field at the end.</p>
<p>I&#8217;ve combined your tip with this: <a href="http://www.shawnolson.net/a/730/mysql-sort-order-with-null.html" rel="nofollow">http://www.shawnolson.net/a/730/mysql-sort-order-with-null.html</a>. I hope that this can help anyone.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Maksym</title>
		<link>http://stereointeractive.com/blog/2007/06/12/propel-queries-using-custom-sql-peer-classes-and-criterion-objects/comment-page-1/#comment-419</link>
		<dc:creator>Maksym</dc:creator>
		<pubDate>Tue, 12 May 2009 12:01:43 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stereodevelopment.com/2007/06/12/propel-queries-using-custom-sql-peer-classes-and-criterion-objects/#comment-419</guid>
		<description>Thank you!!!
Method to compare to column in one table is great!
It&#039;s what I&#039;m looking for</description>
		<content:encoded><![CDATA[<p>Thank you!!!<br />
Method to compare to column in one table is great!<br />
It&#8217;s what I&#8217;m looking for</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rowan</title>
		<link>http://stereointeractive.com/blog/2007/06/12/propel-queries-using-custom-sql-peer-classes-and-criterion-objects/comment-page-1/#comment-350</link>
		<dc:creator>Rowan</dc:creator>
		<pubDate>Tue, 16 Dec 2008 21:47:29 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stereodevelopment.com/2007/06/12/propel-queries-using-custom-sql-peer-classes-and-criterion-objects/#comment-350</guid>
		<description>bharathkumar, see the propel criteria generator: http://propel.jondh.me.uk/</description>
		<content:encoded><![CDATA[<p>bharathkumar, see the propel criteria generator: <a href="http://propel.jondh.me.uk/" rel="nofollow">http://propel.jondh.me.uk/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bharathkumar</title>
		<link>http://stereointeractive.com/blog/2007/06/12/propel-queries-using-custom-sql-peer-classes-and-criterion-objects/comment-page-1/#comment-339</link>
		<dc:creator>bharathkumar</dc:creator>
		<pubDate>Sat, 29 Nov 2008 07:03:26 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stereodevelopment.com/2007/06/12/propel-queries-using-custom-sql-peer-classes-and-criterion-objects/#comment-339</guid>
		<description>SELECT Persons.LastName, Persons.FirstName, Orders.OrderNo
FROM Persons
INNER JOIN Orders
ON Persons.P_Id=Orders.P_Id
ORDER BY Persons.LastName;

how to write this code in propel</description>
		<content:encoded><![CDATA[<p>SELECT Persons.LastName, Persons.FirstName, Orders.OrderNo<br />
FROM Persons<br />
INNER JOIN Orders<br />
ON Persons.P_Id=Orders.P_Id<br />
ORDER BY Persons.LastName;</p>
<p>how to write this code in propel</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: smente</title>
		<link>http://stereointeractive.com/blog/2007/06/12/propel-queries-using-custom-sql-peer-classes-and-criterion-objects/comment-page-1/#comment-254</link>
		<dc:creator>smente</dc:creator>
		<pubDate>Tue, 03 Jun 2008 15:24:25 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stereodevelopment.com/2007/06/12/propel-queries-using-custom-sql-peer-classes-and-criterion-objects/#comment-254</guid>
		<description>Thank You.</description>
		<content:encoded><![CDATA[<p>Thank You.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scott Meves</title>
		<link>http://stereointeractive.com/blog/2007/06/12/propel-queries-using-custom-sql-peer-classes-and-criterion-objects/comment-page-1/#comment-194</link>
		<dc:creator>Scott Meves</dc:creator>
		<pubDate>Fri, 29 Feb 2008 16:15:33 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stereodevelopment.com/2007/06/12/propel-queries-using-custom-sql-peer-classes-and-criterion-objects/#comment-194</guid>
		<description>Tommy, 
I think you are right that you will have to hydrate the objects on your own. The FavoriteBook example added the &#039;cnt&#039; column purely to help sort the results, but if you wanted to retrieve that column along side the book objects, you could do something like this:

&lt;pre class=&quot;code&quot;&gt;&lt;code&gt;
$c = new Criteria();
$c-&gt;addJoin(BookPeer::ID, FavoriteBookPeer::BOOK_ID, Criteria::LEFT_JOIN);
$c-&gt;addAsColumn(&#039;cnt&#039;, &#039;COUNT(&#039;.FavoriteBookPeer::BOOK_ID.&#039;)&#039;);
$c-&gt;addGroupByColumn(BookPeer::ID);
$c-&gt;addDescendingOrderByColumn(&#039;cnt&#039;);

$rs = BookPeer::doSelectRS($c);
$n = BookPeer::NUM_COLUMNS;
$results = array();
while($rs-&gt;next()) {
  $book = new Book();
  $book-&gt;hydrate($rs);
  $bookCount = $rs-&gt;getInt($n+1);
  // or you could do $bookCount = $rs-&gt;getString(&#039;cnt&#039;) but that break if you added conflicting column names
  $results[] = array($book, $bookCount);
}
&lt;/code&gt;&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Tommy,<br />
I think you are right that you will have to hydrate the objects on your own. The FavoriteBook example added the &#8216;cnt&#8217; column purely to help sort the results, but if you wanted to retrieve that column along side the book objects, you could do something like this:</p>
<pre class="code"><code>
$c = new Criteria();
$c->addJoin(BookPeer::ID, FavoriteBookPeer::BOOK_ID, Criteria::LEFT_JOIN);
$c->addAsColumn('cnt', 'COUNT('.FavoriteBookPeer::BOOK_ID.')');
$c->addGroupByColumn(BookPeer::ID);
$c->addDescendingOrderByColumn('cnt');

$rs = BookPeer::doSelectRS($c);
$n = BookPeer::NUM_COLUMNS;
$results = array();
while($rs->next()) {
  $book = new Book();
  $book->hydrate($rs);
  $bookCount = $rs->getInt($n+1);
  // or you could do $bookCount = $rs->getString('cnt') but that break if you added conflicting column names
  $results[] = array($book, $bookCount);
}
</code></pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: tommy</title>
		<link>http://stereointeractive.com/blog/2007/06/12/propel-queries-using-custom-sql-peer-classes-and-criterion-objects/comment-page-1/#comment-193</link>
		<dc:creator>tommy</dc:creator>
		<pubDate>Fri, 29 Feb 2008 14:52:05 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stereodevelopment.com/2007/06/12/propel-queries-using-custom-sql-peer-classes-and-criterion-objects/#comment-193</guid>
		<description>Thanks for this cool article, but how I am able to use the &#039;cnt&#039; property in an object?

$c-&gt;addAsColumn(&#039;cnt&#039;, &#039;COUNT(&#039;.FavoriteBookPeer::BOOK_ID.&#039;)&#039;);

addAsColumns doesn&#039;t get hydrated so I have to do it on my own, right?

Regards,
tommy</description>
		<content:encoded><![CDATA[<p>Thanks for this cool article, but how I am able to use the &#8216;cnt&#8217; property in an object?</p>
<p>$c-&gt;addAsColumn(&#8216;cnt&#8217;, &#8216;COUNT(&#8216;.FavoriteBookPeer::BOOK_ID.&#8217;)');</p>
<p>addAsColumns doesn&#8217;t get hydrated so I have to do it on my own, right?</p>
<p>Regards,<br />
tommy</p>
]]></content:encoded>
	</item>
</channel>
</rss>
