查找ID不在数组中的ID [英] Find where id is not in array of ids

查看:126
本文介绍了查找ID不在数组中的ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

));

我如何做相反的,找到id不同于数组? / p>

解决方案

这应该可以工作:

  $ 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 p>

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

这篇关于查找ID不在数组中的ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆