<?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: findCount vs. hasAny</title>
	<atom:link href="http://cakebaker.42dh.com/2008/07/11/findcount-vs-hasany/feed/" rel="self" type="application/rss+xml" />
	<link>http://cakebaker.42dh.com/2008/07/11/findcount-vs-hasany/</link>
	<description>baking cakes with CakePHP</description>
	<lastBuildDate>Sat, 13 Mar 2010 15:19:16 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2008/07/11/findcount-vs-hasany/comment-page-1/#comment-98261</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Mon, 14 Jul 2008 15:21:51 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=622#comment-98261</guid>
		<description>@all: Thanks for your comments!

@Joaquin: Yes, that&#039;s an additional advantage.

@Abhimanyu: Yes, it is sometimes difficult to remember all those method names, and so it helps if you dig into the source from time to time ;-)

@bfw: Yes, that&#039;s a useful approach if you are not only interested whether there are records but also in the respective records.</description>
		<content:encoded><![CDATA[<p>@all: Thanks for your comments!</p>
<p>@Joaquin: Yes, that&#8217;s an additional advantage.</p>
<p>@Abhimanyu: Yes, it is sometimes difficult to remember all those method names, and so it helps if you dig into the source from time to time ;-)</p>
<p>@bfw: Yes, that&#8217;s a useful approach if you are not only interested whether there are records but also in the respective records.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michał Szajbe</title>
		<link>http://cakebaker.42dh.com/2008/07/11/findcount-vs-hasany/comment-page-1/#comment-98102</link>
		<dc:creator>Michał Szajbe</dc:creator>
		<pubDate>Sun, 13 Jul 2008 23:12:15 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=622#comment-98102</guid>
		<description>I agree, hasAny is more code-reader-friendly. 

It&#039;s worth to note, however, that the difference is only when reading the code, because both methods work the same way - hasAny works by calling find(&#039;count&#039;).</description>
		<content:encoded><![CDATA[<p>I agree, hasAny is more code-reader-friendly. </p>
<p>It&#8217;s worth to note, however, that the difference is only when reading the code, because both methods work the same way &#8211; hasAny works by calling find(&#8216;count&#8217;).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bfw</title>
		<link>http://cakebaker.42dh.com/2008/07/11/findcount-vs-hasany/comment-page-1/#comment-98084</link>
		<dc:creator>bfw</dc:creator>
		<pubDate>Sun, 13 Jul 2008 17:57:19 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=622#comment-98084</guid>
		<description>i do this this way in controllers,

if ($aData = $this-&gt;Model-&gt;find($conditions)) {
  ...
  // here is used $aData
  ...
}

this way i do not have to check if there are any records and then get them</description>
		<content:encoded><![CDATA[<p>i do this this way in controllers,</p>
<p>if ($aData = $this-&gt;Model-&gt;find($conditions)) {<br />
  &#8230;<br />
  // here is used $aData<br />
  &#8230;<br />
}</p>
<p>this way i do not have to check if there are any records and then get them</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Abba Bryant</title>
		<link>http://cakebaker.42dh.com/2008/07/11/findcount-vs-hasany/comment-page-1/#comment-98043</link>
		<dc:creator>Abba Bryant</dc:creator>
		<pubDate>Sun, 13 Jul 2008 05:55:22 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=622#comment-98043</guid>
		<description>Abhimanyu

The two statements are *not* semantically the same. find( &#039;count&#039; ) returns an integer, and thus requires you to run it against a boolean conditional to get a true / false.

The other returns a true / false. They are patently different in return types and thus *cannot* be semantically equal without additional code.</description>
		<content:encoded><![CDATA[<p>Abhimanyu</p>
<p>The two statements are *not* semantically the same. find( &#8216;count&#8217; ) returns an integer, and thus requires you to run it against a boolean conditional to get a true / false.</p>
<p>The other returns a true / false. They are patently different in return types and thus *cannot* be semantically equal without additional code.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Abhimanyu</title>
		<link>http://cakebaker.42dh.com/2008/07/11/findcount-vs-hasany/comment-page-1/#comment-97939</link>
		<dc:creator>Abhimanyu</dc:creator>
		<pubDate>Fri, 11 Jul 2008 22:54:14 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=622#comment-97939</guid>
		<description>Nice as usual, but both the statements are semantically the same :)

“if the number of records that meet the conditions is greater than 0 then do something”.

or

“if there are any records that meet the conditions then do something”.

And its often difficult to remember all the function names :p</description>
		<content:encoded><![CDATA[<p>Nice as usual, but both the statements are semantically the same :)</p>
<p>“if the number of records that meet the conditions is greater than 0 then do something”.</p>
<p>or</p>
<p>“if there are any records that meet the conditions then do something”.</p>
<p>And its often difficult to remember all the function names :p</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joaquín Windmüller</title>
		<link>http://cakebaker.42dh.com/2008/07/11/findcount-vs-hasany/comment-page-1/#comment-97933</link>
		<dc:creator>Joaquín Windmüller</dc:creator>
		<pubDate>Fri, 11 Jul 2008 21:58:24 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=622#comment-97933</guid>
		<description>Specially if you consider that findCount is deprecated and should use find(&#039;count&#039;, array(&#039;conditions&#039; =&gt; $conditions)) instead.

hasAny is not only meaningful but shorter ;)

Nice</description>
		<content:encoded><![CDATA[<p>Specially if you consider that findCount is deprecated and should use find(&#8216;count&#8217;, array(&#8216;conditions&#8217; =&gt; $conditions)) instead.</p>
<p>hasAny is not only meaningful but shorter ;)</p>
<p>Nice</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike karthauser</title>
		<link>http://cakebaker.42dh.com/2008/07/11/findcount-vs-hasany/comment-page-1/#comment-97916</link>
		<dc:creator>Mike karthauser</dc:creator>
		<pubDate>Fri, 11 Jul 2008 17:13:30 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=622#comment-97916</guid>
		<description>A much better method. Fantastic stuff.</description>
		<content:encoded><![CDATA[<p>A much better method. Fantastic stuff.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
