<?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: Conditions in CakePHP RC6</title>
	<atom:link href="http://cakebaker.42dh.com/2006/03/02/conditions-in-cakephp-rc6/feed/" rel="self" type="application/rss+xml" />
	<link>http://cakebaker.42dh.com/2006/03/02/conditions-in-cakephp-rc6/</link>
	<description>baking cakes with CakePHP</description>
	<lastBuildDate>Tue, 31 Jan 2012 15:12:14 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2006/03/02/conditions-in-cakephp-rc6/comment-page-1/#comment-161687</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Fri, 14 May 2010 14:59:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.cakebaker.42dh.com/?p=129#comment-161687</guid>
		<description>@fairuz: Something like:
&lt;pre&gt;
&lt;code&gt;
$conditions = array(&#039;YourModel.&#039; . $searchFilter . &#039; LIKE&#039; =&gt; &#039;%&#039; . $keyword . &#039;%&#039;);
&lt;/code&gt;
&lt;/pre&gt;
should do the trick (make sure $searchFilter is an allowed value before using it).

Hope this helps!</description>
		<content:encoded><![CDATA[<p>@fairuz: Something like:</p>
<pre>
<code>$conditions = array('YourModel.' . $searchFilter . ' LIKE' =&gt; '%' . $keyword . '%');</code>
</pre>
<p>should do the trick (make sure $searchFilter is an allowed value before using it).</p>
<p>Hope this helps!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: fairuz</title>
		<link>http://cakebaker.42dh.com/2006/03/02/conditions-in-cakephp-rc6/comment-page-1/#comment-161595</link>
		<dc:creator>fairuz</dc:creator>
		<pubDate>Fri, 14 May 2010 02:17:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.cakebaker.42dh.com/?p=129#comment-161595</guid>
		<description>i have some problems about my query in controller... in search.ctp file i am generate my code like this

&lt;code&gt;
//search.ctp
$selectSearchFilter = array(&#039;a&#039;=&gt;&#039;column1&#039;,&#039;b&#039;=&gt;&#039;column b&#039;, &#039;c&#039;=&gt;&#039;column c &#039; );
$form-&gt;select(&#039;searchFilter&#039;,$selectFitlerSearch);
$form-&gt;input(&#039;keyword&#039;,array(&#039;type&#039;=&gt;&#039;text&#039;));
$form-&gt;end(&#039;Search&#039;);

//in tempModels_controllers

function search()
{
  if(!empty($this-&gt;data()))
     {
        $keyword = $this-&gt;data[&#039;Pruf&#039;][&#039;keyword&#039;];
        $selectFilter = $this-&gt;data[&#039;Pruf&#039;][&#039;searchFitler&#039;];

        // i dont know how to generate filter SQL... :-(
       // select * from table where $searchFilter Like %$keyword%


        $result = $this-&gt;find(&#039;all&#039;,$conditions);
      }

&lt;/code&gt;

Questions : How to generate cakephp sql like about statements??</description>
		<content:encoded><![CDATA[<p>i have some problems about my query in controller&#8230; in search.ctp file i am generate my code like this</p>
<pre><code>//search.ctp
$selectSearchFilter = array('a'=&gt;'column1','b'=&gt;'column b', 'c'=&gt;'column c ' );
$form-&gt;select('searchFilter',$selectFitlerSearch);
$form-&gt;input('keyword',array('type'=&gt;'text'));
$form-&gt;end('Search');

//in tempModels_controllers

function search()
{
  if(!empty($this-&gt;data()))
     {
        $keyword = $this-&gt;data['Pruf']['keyword'];
        $selectFilter = $this-&gt;data['Pruf']['searchFitler'];

        // i dont know how to generate filter SQL... :-(
       // select * from table where $searchFilter Like %$keyword%


        $result = $this-&gt;find('all',$conditions);
      }</code></pre>
<p>Questions : How to generate cakephp sql like about statements??</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sarah</title>
		<link>http://cakebaker.42dh.com/2006/03/02/conditions-in-cakephp-rc6/comment-page-1/#comment-151055</link>
		<dc:creator>Sarah</dc:creator>
		<pubDate>Tue, 09 Mar 2010 17:52:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.cakebaker.42dh.com/?p=129#comment-151055</guid>
		<description>Thanks for the reply. It was part of an attempt to build queries based on pseudo &quot;views&quot; rather than having custom sql. On its own it might seem odd but when you put the building blocks together and are looking for available resources (those with complete/finished orders) it did make sense.

:)</description>
		<content:encoded><![CDATA[<p>Thanks for the reply. It was part of an attempt to build queries based on pseudo &#8220;views&#8221; rather than having custom sql. On its own it might seem odd but when you put the building blocks together and are looking for available resources (those with complete/finished orders) it did make sense.</p>
<p>:)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2006/03/02/conditions-in-cakephp-rc6/comment-page-1/#comment-151036</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Tue, 09 Mar 2010 15:40:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.cakebaker.42dh.com/?p=129#comment-151036</guid>
		<description>@Sarah: Thanks for your comment.

Right now I don&#039;t see a way around this, though I have to admit I don&#039;t understand your approach completely. Having a relationship YourModel hasMany CompleteOrder seems a bit odd to me ;-)</description>
		<content:encoded><![CDATA[<p>@Sarah: Thanks for your comment.</p>
<p>Right now I don&#8217;t see a way around this, though I have to admit I don&#8217;t understand your approach completely. Having a relationship YourModel hasMany CompleteOrder seems a bit odd to me ;-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sarah</title>
		<link>http://cakebaker.42dh.com/2006/03/02/conditions-in-cakephp-rc6/comment-page-1/#comment-150749</link>
		<dc:creator>Sarah</dc:creator>
		<pubDate>Sun, 07 Mar 2010 23:08:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.cakebaker.42dh.com/?p=129#comment-150749</guid>
		<description>I know this is old  but it&#039;s the best Google could find me.

Basically I want my new model to be a &quot;view&quot; of an existing model.

I therefore to add to the join conditions so I have created a hasmany condition in the parent model
&lt;code&gt;
&#039;Completeorder&#039; =&gt; array(
    &#039;className&#039;     =&gt; &#039;Completeorder&#039;,
    &#039;conditions&#039;    =&gt; &quot;Completeorder.status in (&#039;Pending Pickup&#039;,&#039;Complete&#039;)&quot;,
    &#039;order&#039;         =&gt; &#039;Completeorder.pickupdate DESC&#039;
)
&lt;/code&gt;
However when I view the query it&#039;s put the conditions in the where statement. This means that my left join isn&#039;t returning null for those parents with no complete orders - its omitting them altogether.

I&#039;m happy to have a custom query but I&#039;d also like to use Cake where possible. Anyway around this?</description>
		<content:encoded><![CDATA[<p>I know this is old  but it&#8217;s the best Google could find me.</p>
<p>Basically I want my new model to be a &#8220;view&#8221; of an existing model.</p>
<p>I therefore to add to the join conditions so I have created a hasmany condition in the parent model<br />
<pre><code>'Completeorder' =&gt; array(
    'className'     =&gt; 'Completeorder',
    'conditions'    =&gt; "Completeorder.status in ('Pending Pickup','Complete')",
    'order'         =&gt; 'Completeorder.pickupdate DESC'
)</code></pre><br />
However when I view the query it&#8217;s put the conditions in the where statement. This means that my left join isn&#8217;t returning null for those parents with no complete orders &#8211; its omitting them altogether.</p>
<p>I&#8217;m happy to have a custom query but I&#8217;d also like to use Cake where possible. Anyway around this?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2006/03/02/conditions-in-cakephp-rc6/comment-page-1/#comment-106766</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Wed, 17 Sep 2008 15:06:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.cakebaker.42dh.com/?p=129#comment-106766</guid>
		<description>@Ellen: Yes, the syntax was changed recently so I modified the article accordingly. Thanks for the hint!</description>
		<content:encoded><![CDATA[<p>@Ellen: Yes, the syntax was changed recently so I modified the article accordingly. Thanks for the hint!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ellen</title>
		<link>http://cakebaker.42dh.com/2006/03/02/conditions-in-cakephp-rc6/comment-page-1/#comment-106759</link>
		<dc:creator>Ellen</dc:creator>
		<pubDate>Wed, 17 Sep 2008 12:45:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.cakebaker.42dh.com/?p=129#comment-106759</guid>
		<description>I can&#039;t do it like your example, but I can it when I change somethings:

$this-&gt;set(&quot;country&quot;, $this-&gt;Country-&gt;find(&quot;all&quot;, array(&#039;conditions&#039;=&gt;array(&#039;Country.nom_country LIKE&#039;=&gt;&#039;%South%&#039;))));

Thank you so much!!!</description>
		<content:encoded><![CDATA[<p>I can&#8217;t do it like your example, but I can it when I change somethings:</p>
<p>$this-&gt;set(&#8220;country&#8221;, $this-&gt;Country-&gt;find(&#8220;all&#8221;, array(&#8216;conditions&#8217;=&gt;array(&#8216;Country.nom_country LIKE&#8217;=&gt;&#8217;%South%&#8217;))));</p>
<p>Thank you so much!!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2006/03/02/conditions-in-cakephp-rc6/comment-page-1/#comment-101270</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Thu, 31 Jul 2008 15:23:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.cakebaker.42dh.com/?p=129#comment-101270</guid>
		<description>@olda: Hm, what do you mean with &quot;$conditions property&quot;? The model doesn&#039;t contain such a property. Or do you mean the &quot;conditions&quot; option you can specify when defining an association? In that case you can specify the conditions as a string as shown in my previous comment. 

Hope that helps!</description>
		<content:encoded><![CDATA[<p>@olda: Hm, what do you mean with &#8220;$conditions property&#8221;? The model doesn&#8217;t contain such a property. Or do you mean the &#8220;conditions&#8221; option you can specify when defining an association? In that case you can specify the conditions as a string as shown in my previous comment. </p>
<p>Hope that helps!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: olda</title>
		<link>http://cakebaker.42dh.com/2006/03/02/conditions-in-cakephp-rc6/comment-page-1/#comment-100938</link>
		<dc:creator>olda</dc:creator>
		<pubDate>Tue, 29 Jul 2008 21:16:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.cakebaker.42dh.com/?p=129#comment-100938</guid>
		<description>oh je, but i mean somthing more like specify it in model class in $conditions property 
&lt;code&gt;
array (&quot;or&quot; =&gt;
    array
    (
        &quot;A&quot; =&gt; &quot;B&quot;
        &quot;B&quot; =&gt; &quot;C&quot;
    )
)
&lt;/code&gt;
and some far in code use find function with additional conditions. 
btw, conditions that i use in call find function will join with conditions specify in model?</description>
		<content:encoded><![CDATA[<p>oh je, but i mean somthing more like specify it in model class in $conditions property<br />
<pre><code>array ("or" =&gt;
    array
    (
        "A" =&gt; "B"
        "B" =&gt; "C"
    )
)</code></pre><br />
and some far in code use find function with additional conditions.<br />
btw, conditions that i use in call find function will join with conditions specify in model?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2006/03/02/conditions-in-cakephp-rc6/comment-page-1/#comment-100909</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Tue, 29 Jul 2008 14:56:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.cakebaker.42dh.com/?p=129#comment-100909</guid>
		<description>@olda: You could write it in the following way:
&lt;code&gt;
$this-&gt;YourModel-&gt;find(&#039;all&#039;, array(&#039;conditions&#039; =&gt; &#039;(A=B OR B=C) AND (A=D OR B=D)&#039;));
&lt;/code&gt;
But you have to be careful with this approach. It is very easy to introduce an SQL injection vulnerability because the values are not automatically escaped by cake!

Anyway, hope it helps!</description>
		<content:encoded><![CDATA[<p>@olda: You could write it in the following way:<br />
<code>$this-&gt;YourModel-&gt;find('all', array('conditions' =&gt; '(A=B OR B=C) AND (A=D OR B=D)'));</code><br />
But you have to be careful with this approach. It is very easy to introduce an SQL injection vulnerability because the values are not automatically escaped by cake!</p>
<p>Anyway, hope it helps!</p>
]]></content:encoded>
	</item>
</channel>
</rss>

