Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I took me the better part of three hours. But I finally cracked it. </p> <p>The double underscore pattern comes from <a href="http://groups.google.com/group/cake-php/browse_thread/thread/2fa2cd69422dfcf/81e7a5ea50266a15" rel="nofollow noreferrer">here</a>. It's an extension of the mysql database driver that lets you do those to <a href="http://www.google.com/url?sa=D&amp;q=http://i-love-cake.pastebin.com/f78d0639a&amp;usg=AFQjCNF6JVP6AKCH_SB7qKbXmASmw4IFkg" rel="nofollow noreferrer">add any calculated value as a field</a>. </p> <p>Furthermore I had to hack out the field checking in cake's base controller. Find the code block around line 1000 that starts with:</p> <pre><code>if (!empty($options['order']) &amp;&amp; is_array($options['order'])) { // lots of code goes here } </code></pre> <p>And replace the entire block (i cut it for brevity) it with this:</p> <pre><code>if (!empty($options['order']) &amp;&amp; is_array($options['order'])) { $key = key($options['order']); $value = $options['order'][$key]; $key = preg_replace('/[^a-zA-Z_.]/', '', $key); $options['order'] = array(); $options['order'][$key] = $value; } </code></pre> <p>This field validation is VERY naive, and basically just applies a whitelist to avoid any simple sql injections, but your users will be able to mess up the query by changing the url themselves. I'm just using this for an internal backend so it'll have to do for now. </p> <p>I also stumbled over this link, it would seem there will be a less hacky way to do this in cake 1.3 (the code above was written for 1.2.5)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload