I have already written about defining conditions in RC6, but unfortunately, most of it is no longer valid ;-) So, in this post I will show the current way of defining conditions.

First some examples using the array syntax:

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

When using several conditions in the array, they are combined with an “AND”.

If you do not want for some reason that CakePHP does quote a value automatically, you can use “-!” as shown in the next example. I think you do not have to use “-!” very often, at least I do not see any use cases for it ;-)

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

The most flexible way is to use a simple string with your condition(s). In this case you have to single quote the values, as shown in the example:

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