<?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: SQL Conditions &#8211; A CakePHP Component Class</title>
	<atom:link href="http://www.jjwdesign.com/blog/sql-conditions-a-cakephp-component-class.html/feed" rel="self" type="application/rss+xml" />
	<link>http://www.jjwdesign.com/blog/sql-conditions-a-cakephp-component-class.html</link>
	<description>Home for my many thoughts...</description>
	<lastBuildDate>Mon, 28 Jun 2010 02:55:16 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: admin</title>
		<link>http://www.jjwdesign.com/blog/sql-conditions-a-cakephp-component-class.html/comment-page-1#comment-829</link>
		<dc:creator>admin</dc:creator>
		<pubDate>Mon, 19 Apr 2010 09:02:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.jjwdesign.com/blog/?p=90#comment-829</guid>
		<description>You were close. I believe it should be something like:

var $criteria_conditions = array(
   array(
      &#039;name&#039; =&gt; &#039;search_sdt&#039;,
      &#039;fields&#039; =&gt; array(&#039;Job.start_date&#039;),
      &#039;condition&#039; =&gt;  &#039;&gt;&#039;
   ),
);
</description>
		<content:encoded><![CDATA[<p>You were close. I believe it should be something like:</p>
<p>var $criteria_conditions = array(<br />
   array(<br />
      &#8216;name&#8217; => &#8216;search_sdt&#8217;,<br />
      &#8216;fields&#8217; => array(&#8216;Job.start_date&#8217;),<br />
      &#8216;condition&#8217; =>  &#8216;>&#8217;<br />
   ),<br />
);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: grggnn</title>
		<link>http://www.jjwdesign.com/blog/sql-conditions-a-cakephp-component-class.html/comment-page-1#comment-824</link>
		<dc:creator>grggnn</dc:creator>
		<pubDate>Sat, 16 Jan 2010 11:49:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.jjwdesign.com/blog/?p=90#comment-824</guid>
		<description>hello and thanks for making such a useful component. i&#039;m kind of n00b to cakePHP so naturally i&#039;m running into some problems. essentially, i&#039;m trying to search through a list of records by date. ideally, the user would specify a date and the app would search the table for all records whose &#039;start_date&#039; field was &lt; the date specified. so if the search criteria was Jan 1, 2008 - it would pull up everything before that date.

here&#039;s my setup:

table name: jobs
search field name: start_date


default.ctp
&lt;code&gt;
create(&#039;Job&#039;, array(&#039;action&#039; =&gt; &#039;index&#039;, &#039;class&#039; =&gt; &#039;advanced_search&#039;));
			echo $form-&gt;input(&#039;search_sdt&#039;, array(&#039;default&#039; =&gt; @$this-&gt;params[&#039;named&#039;][&#039;search_sdt&#039;],&#039;div&#039; =&gt; false, &#039;type&#039; =&gt; &#039;date&#039;));
			echo $form-&gt;submit(&#039;Go!&#039;, array(&#039;div&#039; =&gt; false,));
			echo $form-&gt;end();
			
			echo $form-&gt;create(&#039;Job&#039;, array(&#039;action&#039; =&gt; &#039;index&#039;, &#039;class&#039; =&gt; &#039;advanced_search&#039;));
			echo $form-&gt;input(&#039;clear_conditions&#039;, array(&#039;type&#039; =&gt; &#039;hidden&#039;, &#039;value&#039; =&gt; 1, &#039;div&#039; =&gt; false,));
			echo $form-&gt;submit(&#039;Reset&#039;, array(&#039;div&#039; =&gt; false,));
			echo $form-&gt;end();
			?&gt;
&lt;/code&gt;

jobs_controller.php
&lt;code&gt;
var $components = array(
			&#039;SqlConditions&#039; =&gt; array(
			&#039;conditions&#039; =&gt; &#039;criteria_conditions&#039;,
			&#039;admin_conditions&#039; =&gt; &#039;admin_criteria_conditions&#039;,
			&#039;active_actions&#039; =&gt; array(&#039;index&#039;, &#039;admin_index&#039;),
		),
	);
	
	// For use with SqlConditions component.
	// Regular Site Search Conditions
	var $criteria_conditions = array(
		array(&#039;name&#039; =&gt; &#039;search_sdt&#039;, &#039;fields&#039; =&gt; &#039;Job.start_date&#039;, &#039;type&#039; =&gt; &#039;date&#039;, &#039;condition&#039; =&gt; &#039; &#039;admin_search_sdt&#039;, &#039;fields&#039; =&gt; &#039;Job.start_date&#039;, &#039;type&#039; =&gt; &#039;date&#039;, &#039;condition&#039; =&gt; &#039;SqlConditions-&gt;build();
		$this-&gt;Job-&gt;recursive = 0;
		$this-&gt;set(&#039;jobs&#039;, $this-&gt;paginate($sql_conditions));
	}
&lt;/code&gt;

i&#039;ve also copied sql_conditions.php into controllers/components.
any help and/or light you can shed on this would be super appreciated.

thanks!</description>
		<content:encoded><![CDATA[<p>hello and thanks for making such a useful component. i&#8217;m kind of n00b to cakePHP so naturally i&#8217;m running into some problems. essentially, i&#8217;m trying to search through a list of records by date. ideally, the user would specify a date and the app would search the table for all records whose &#8216;start_date&#8217; field was &lt; the date specified. so if the search criteria was Jan 1, 2008 &#8211; it would pull up everything before that date.</p>
<p>here&#039;s my setup:</p>
<p>table name: jobs<br />
search field name: start_date</p>
<p>default.ctp<br />
<code><br />
create('Job', array('action' =&gt; 'index', 'class' =&gt; 'advanced_search'));<br />
			echo $form-&gt;input('search_sdt', array('default' =&gt; @$this-&gt;params['named']['search_sdt'],'div' =&gt; false, 'type' =&gt; 'date'));<br />
			echo $form-&gt;submit('Go!', array('div' =&gt; false,));<br />
			echo $form-&gt;end();</p>
<p>			echo $form-&gt;create('Job', array('action' =&gt; 'index', 'class' =&gt; 'advanced_search'));<br />
			echo $form-&gt;input('clear_conditions', array('type' =&gt; 'hidden', 'value' =&gt; 1, 'div' =&gt; false,));<br />
			echo $form-&gt;submit('Reset', array('div' =&gt; false,));<br />
			echo $form-&gt;end();<br />
			?&gt;<br />
</code></p>
<p>jobs_controller.php<br />
<code><br />
var $components = array(<br />
			'SqlConditions' =&gt; array(<br />
			'conditions' =&gt; 'criteria_conditions',<br />
			'admin_conditions' =&gt; 'admin_criteria_conditions',<br />
			'active_actions' =&gt; array('index', 'admin_index'),<br />
		),<br />
	);</p>
<p>	// For use with SqlConditions component.<br />
	// Regular Site Search Conditions<br />
	var $criteria_conditions = array(<br />
		array('name' =&gt; 'search_sdt', 'fields' =&gt; 'Job.start_date', 'type' =&gt; 'date', 'condition' =&gt; ' 'admin_search_sdt', 'fields' =&gt; 'Job.start_date', 'type' =&gt; 'date', 'condition' =&gt; 'SqlConditions-&gt;build();<br />
		$this-&gt;Job-&gt;recursive = 0;<br />
		$this-&gt;set('jobs', $this-&gt;paginate($sql_conditions));<br />
	}<br />
</code></p>
<p>i&#8217;ve also copied sql_conditions.php into controllers/components.<br />
any help and/or light you can shed on this would be super appreciated.</p>
<p>thanks!</p>
]]></content:encoded>
	</item>
</channel>
</rss>

