I have a table called Users and the following find works fine:
$users = $this->User->find('list', array('conditions'=>array('User.id'=>1)));
However, if I try to get a list of users with "User.id != 1" or "User.id >= 5", the find does not return data.
The syntax I have used is
$users = $this->User->find('list', array('conditions'=>array('User.id'=>'<> 1')));
AND
$users = $this->User->find('list', array('conditions'=>array('User.id'=>'>= 1')));
The debug query generated by Cake for the User.id => '<> 1') case is
SELECT `User`.`id`, `User`.`first_name` FROM `mesh2`.`users` AS `User` WHERE `User`.`id` = '<>1',
which seems to be incorrect.
I have used the examples from Alvin’s site. Any ideas?
You need to put
>=on the correct side of the array:as documented in the “official” documentation:
http://book.cakephp.org/2.0/en/models/retrieving-your-data.html#complex-find-conditions