16
的陣列要查找ID,其值等於ID數組的ID:查找其中id是不是在IDS
$this->YourModel->find('all', array(
'conditions' => array(
"YourModel.id" => array(1, 2, 3, 4)
)
));
我怎麼能反其道而行之,發現其中的ID是不同於元素一個ID數組?
的陣列要查找ID,其值等於ID數組的ID:查找其中id是不是在IDS
$this->YourModel->find('all', array(
'conditions' => array(
"YourModel.id" => array(1, 2, 3, 4)
)
));
我怎麼能反其道而行之,發現其中的ID是不同於元素一個ID數組?
這應該工作:
$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