On Thu, Jun 26, 2008 at 4:08 PM, Ruslan Zakirov &lt;<a href="mailto:ruz@bestpractical.com">ruz@bestpractical.com</a>&gt; wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
subclauses is the way to deal with that and open_paren/close_paren.<br>
<br>
something like:<br>
$col-&gt;limit( column =&gt; &#39;parent&#39;, value =&gt; 12 );<br>
$col-&gt;limit( column =&gt; &#39;task_type&#39;, value =&gt; &#39;action&#39; );<br>
$col-&gt;open_paren(&quot;my_clause&quot;);<br>
$col-&gt;limit( subclause =&gt; &quot;my_clause&quot;, column =&gt; &#39;status&#39;, value =&gt; &#39;open&#39; );<br>
$col-&gt;open_paren(&quot;my_clause&quot;);<br>
$col-&gt;limit( subclause =&gt; &quot;my_clause&quot;, column =&gt; &#39;status&#39;, value =&gt;<br>
&#39;done&#39;, entry_aggregator =&gt; &#39;OR&#39; );<br>
$col-&gt;limit( subclause =&gt; &quot;my_clause&quot;, column =&gt; &#39;completed_on&#39;,<br>
<div class="Ih2E3d">operator =&gt; &#39;&gt;=&#39;, value =&gt; &#39;2008-06-26 11:39:22&#39; );<br>
</div>$col-&gt;close_paren(&quot;my_clause&quot;);<br>
$col-&gt;close_paren(&quot;my_clause&quot;);</blockquote><div><br>Thank you. I&#39;ve been trying to understand the use of subclauses and open_paren/close_paren, but was at loss. I&#39;ll put that into the docs. I do note, however, that open_paren/close_paren have a &quot;don&#39;t do this, we&#39;ll change this as soon as we figure out how&quot; note on it.<br>
<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
<br>
May be it&#39;s not ideal, but pure SQL is not a good too.</blockquote><div><br>No, it is not ideal, at least not as long as we can&#39;t get anyone to agree on what SQL is. However, if you&#39;re writing a quick and dirty app, SQL is an excellent shortcut. I don&#39;t always need the ideal solution, but one that is simple and works.<br>
&nbsp;</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
<br>
With tisql you can do:<br>
<br>
$col-&gt;tisql( &quot;parent = 12 AND task_type = &#39;action&#39; AND (status =<br>
<div class="Ih2E3d">&#39;open&#39; OR (status = &#39;done&#39; AND completed_on &gt;= &#39;2008-06-26<br>
</div>11:39:22&#39;))&quot; );<br>
<br>
But I found some design problems with tisql and have to rethink<br>
language to address issues with one-to-many relations.</blockquote><div><br>I would love to see this incorporated into the trunk. But until then...<br><br>Cheers,<br>Sterling<br>&nbsp;<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
<div><div></div><div class="Wj3C7c"><br>
<br>
<br>
On Thu, Jun 26, 2008 at 9:23 PM, Sterling Hanenkamp<br>
&lt;<a href="mailto:sterling@hanenkamp.com">sterling@hanenkamp.com</a>&gt; wrote:<br>
&gt; Every so often I want to defenestrate Jifty::DBI for the simple fact that I<br>
&gt; cannot describe a basic WHERE clause with it. For example, the query:<br>
&gt;<br>
&gt; SELECT *<br>
&gt; FROM tasks<br>
&gt; WHERE parent = 12 AND task_type = &#39;action&#39; AND (status = &#39;open&#39; OR (status =<br>
&gt; &#39;done&#39; AND completed_on &gt;= &#39;2008-06-26 11:39:22&#39;))<br>
&gt;<br>
&gt; Is there a way to do this? I haven&#39;t found a combination of limits and<br>
&gt; subclauses that will let me do this that works. The code within limit() is<br>
&gt; pretty complicated, so I haven&#39;t been able to unravel what it is doing, let<br>
&gt; alone how this is supposed to work. I&#39;ll write up a complex query example in<br>
&gt; the documentation if someone will give me a demonstration on how this is<br>
&gt; supposed to be done. I have not found a good example of a complex query<br>
&gt; either.<br>
&gt;<br>
&gt; My other issue with limit is that the format used in limit() is pretty<br>
&gt; verbose. Has there been any consideration for allowing arbitrary SQL to be<br>
&gt; used. I.e., this is arguably more straitforward:<br>
&gt;<br>
&gt; $tasks-&gt;limit(sql =&gt; &quot;completed_on &gt;= &#39;2008-06-26 11:39:22&#39;&quot;);<br>
&gt;<br>
&gt; than:<br>
&gt;<br>
&gt; $tasks-&gt;limit(column =&gt; &#39;completed_on&#39;, operator =&gt; &#39;&gt;=&#39;, value =&gt;<br>
&gt; &#39;2008-06-26 11:39:22&#39;);<br>
&gt;<br>
&gt; Or the use of a more flexible and compact format for limits, such as is used<br>
&gt; by SQL::Abstract:<br>
&gt;<br>
&gt; $tasks-&gt;limit(abstract =&gt; [ completed_on =&gt; [ &#39;&gt;=&#39;, &#39;2008-06-26 11:39:22&#39; ]<br>
&gt; ]);<br>
&gt;<br>
&gt; Cheers,<br>
&gt; Sterling<br>
&gt;<br>
</div></div>&gt; _______________________________________________<br>
&gt; jifty-devel mailing list<br>
&gt; <a href="mailto:jifty-devel@lists.jifty.org">jifty-devel@lists.jifty.org</a><br>
&gt; <a href="http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-devel" target="_blank">http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-devel</a><br>
&gt;<br>
&gt;<br>
<font color="#888888"><br>
<br>
<br>
--<br>
Best regards, Ruslan.<br>
_______________________________________________<br>
jifty-devel mailing list<br>
<a href="mailto:jifty-devel@lists.jifty.org">jifty-devel@lists.jifty.org</a><br>
<a href="http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-devel" target="_blank">http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-devel</a><br>
</font></blockquote></div><br>