<?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: Named scope in CakePHP</title>
	<atom:link href="http://codetunes.com/2008/09/05/named-scope-in-cakephp/feed/" rel="self" type="application/rss+xml" />
	<link>http://codetunes.com/2008/09/05/named-scope-in-cakephp/</link>
	<description>Web applications, software engineering, Ruby on Rails, Cake PHP, JavaScript, etc.</description>
	<pubDate>Fri, 12 Mar 2010 07:07:16 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: links for 2009-02-12 &#171; Richard@Home</title>
		<link>http://codetunes.com/2008/09/05/named-scope-in-cakephp/comment-page-1/#comment-1042</link>
		<dc:creator>links for 2009-02-12 &#171; Richard@Home</dc:creator>
		<pubDate>Thu, 12 Feb 2009 19:13:35 +0000</pubDate>
		<guid isPermaLink="false">http://codetunes.com/?p=55#comment-1042</guid>
		<description>[...] Named scope in CakePHP at code tunes A port of a useful Rails feature. (tags: cakephp namedscope scope behaviour) [...]</description>
		<content:encoded><![CDATA[<p>[...] Named scope in CakePHP at code tunes A port of a useful Rails feature. (tags: cakephp namedscope scope behaviour) [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michał Szajbe</title>
		<link>http://codetunes.com/2008/09/05/named-scope-in-cakephp/comment-page-1/#comment-977</link>
		<dc:creator>Michał Szajbe</dc:creator>
		<pubDate>Thu, 11 Dec 2008 20:58:08 +0000</pubDate>
		<guid isPermaLink="false">http://codetunes.com/?p=55#comment-977</guid>
		<description>Thanks, Wojtek. I'll look into the issue soon.</description>
		<content:encoded><![CDATA[<p>Thanks, Wojtek. I&#8217;ll look into the issue soon.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Wojtek</title>
		<link>http://codetunes.com/2008/09/05/named-scope-in-cakephp/comment-page-1/#comment-970</link>
		<dc:creator>Wojtek</dc:creator>
		<pubDate>Wed, 10 Dec 2008 14:37:01 +0000</pubDate>
		<guid isPermaLink="false">http://codetunes.com/?p=55#comment-970</guid>
		<description>In current implementation your behaviour doesn't properly handle key-value conditions like:
'activated' =&gt; array('User.activated' =&gt; 1)
(only 'activated' =&gt; array('User.activated = 1')) works currently.

This is because
foreach ($conditions as $condition) {
  $queryData['conditions'][] = $condition;
}
loop ignores keys (it uses '[]' to assign elements).

If you change it to something like:
foreach ($conditions as $key =&gt; $condition) {
  if (is_string($key)) {
    $queryData['conditions'][$key] = $condition;                
  } else {
    $queryData['conditions'][] = $condition;
  }
}
it will work properly for both cases (with and without array key).
I use this improved version of your code in one of my projects and it works very nicely (keyd conditions are IMO nicer to use and more standard for Cake 1.2 than plain string ones).</description>
		<content:encoded><![CDATA[<p>In current implementation your behaviour doesn&#8217;t properly handle key-value conditions like:<br />
&#8216;activated&#8217; =&gt; array(&#8217;User.activated&#8217; =&gt; 1)<br />
(only &#8216;activated&#8217; =&gt; array(&#8217;User.activated = 1&#8242;)) works currently.</p>
<p>This is because<br />
foreach ($conditions as $condition) {<br />
  $queryData['conditions'][] = $condition;<br />
}<br />
loop ignores keys (it uses &#8216;[]&#8216; to assign elements).</p>
<p>If you change it to something like:<br />
foreach ($conditions as $key =&gt; $condition) {<br />
  if (is_string($key)) {<br />
    $queryData['conditions'][$key] = $condition;<br />
  } else {<br />
    $queryData['conditions'][] = $condition;<br />
  }<br />
}<br />
it will work properly for both cases (with and without array key).<br />
I use this improved version of your code in one of my projects and it works very nicely (keyd conditions are IMO nicer to use and more standard for Cake 1.2 than plain string ones).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: NamedScope or CakePHP - Developing With Style</title>
		<link>http://codetunes.com/2008/09/05/named-scope-in-cakephp/comment-page-1/#comment-955</link>
		<dc:creator>NamedScope or CakePHP - Developing With Style</dc:creator>
		<pubDate>Thu, 20 Nov 2008 14:37:36 +0000</pubDate>
		<guid isPermaLink="false">http://codetunes.com/?p=55#comment-955</guid>
		<description>[...] a few months ago I read this blog post and discovered that someone had created similar functionality for CakePHP, in the form of a model [...]</description>
		<content:encoded><![CDATA[<p>[...] a few months ago I read this blog post and discovered that someone had created similar functionality for CakePHP, in the form of a model [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joel Moss</title>
		<link>http://codetunes.com/2008/09/05/named-scope-in-cakephp/comment-page-1/#comment-933</link>
		<dc:creator>Joel Moss</dc:creator>
		<pubDate>Fri, 05 Sep 2008 23:37:42 +0000</pubDate>
		<guid isPermaLink="false">http://codetunes.com/?p=55#comment-933</guid>
		<description>Nice, very nice!</description>
		<content:encoded><![CDATA[<p>Nice, very nice!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
