Yesterday, I wrote already about the new syntax for conditions. Well, most of it is outdated today ;-) The examples I showed do no longer work, they cause an “sql syntax” error:

$this->User->findAll(array('User.firstname' => '= Daniel'));
$this->User->findAll(array('User.firstname' => 'LIKE %an%'));
$this->User->findAll(array('User.age' => '> 18'));

To make them work again, we have to add a space to the values:

$this->User->findAll(array('User.firstname' => ' = Daniel'));
$this->User->findAll(array('User.firstname' => ' LIKE %an%'));
$this->User->findAll(array('User.age' => ' > 18'));

There are also some new features. By default, all conditions are concatenated with “AND”. If you want to use an “OR”, you have to do it in the following way:

$this->User->findAll(array('User.firstname' => ' = Daniel',
                                               ' OR User.firstname' => ' = Hugo'));

It is now also possible to use “–return” for a value, i.e. your value will not be quoted by CakePHP. Example:

$this->User->findAll(array('User.firstname' => "--return = 'Daniel'"));

Update (2006-02-28): The examples in this post are no longer valid!