19

要查找其值等于 id 数组的 id 的 id:

$this->YourModel->find('all', array(
    'conditions' => array(
        "YourModel.id" => array(1, 2, 3, 4)
    )
));

我该如何做相反的事情,找到 id 与 id 数组不同的元素?

4

1 回答 1

35

这应该有效:

$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

于 2013-01-24T19:17:24.320 回答