问题
To find id whose value is equal to the id of an array of ids:
$this->YourModel->find('all', array(
'conditions' => array(
"YourModel.id" => array(1, 2, 3, 4)
)
));
How I can do the opposite, find elements where the ids are different than an array of ids?
回答1:
This should work:
$this->YourModel->find('all', array(
'conditions' => array(
"NOT" => array( "YourModel.id" => array(1, 2, 3, 4) )
)
));
http://book.cakephp.org/2.0/en/models/retrieving-your-data.html#complex-find-conditions
来源:https://stackoverflow.com/questions/14508682/find-where-id-is-not-in-array-of-ids