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?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With