Php MongoDB过滤
我有一个数组,它是Mongodb的过滤器。 但它不起作用,我不明白为什么Php MongoDB过滤,php,arrays,mongodb,nosql,Php,Arrays,Mongodb,Nosql,我有一个数组,它是Mongodb的过滤器。 但它不起作用,我不明白为什么 Array ( [deleted] => Array ( [$ne] => 1 ) [public] => 1 [_id] => Array ( [$nin] => Array ( [0] => MongoId Object
Array
(
[deleted] => Array
(
[$ne] => 1
)
[public] => 1
[_id] => Array
(
[$nin] => Array
(
[0] => MongoId Object
(
[$id] => 525becec38aa9e28201f1d68
)
[1] => MongoId Object
(
[$id] => 525becb438aa9e963a1f1d55
)
[2] => MongoId Object
(
[$id] => 525bec7438aa9e8d3a1f1d56
)
[3] => MongoId Object
(
[$id] => 525bec1438aa9e6c6d1f1d69
)
[4] => MongoId Object
(
[$id] => 525bebcf38aa9e8c3a1f1d57
)
[5] => MongoId Object
(
[$id] => 525beb3038aa9e8d3a1f1d55
)
)
)
)
我需要找到标识符不在列表中的所有对象。您的查询应如下所示:
$filter = array(
'_id' => array(
'$nin' => array(
new MongoId('525becec38aa9e28201f1d68'),
//etc...
)
),
'deleted' => array(
'$ne' => 1
)
);
$result = $this->mongo->questions->find($filter)->sort(//however you're sorting);
不确定为什么要将结果限制为一个文档,除非这是您真正想要的。这是什么编程语言?我想可能是PHP,但我不确定。请添加适当的标签。我不明白你想做什么。请更具体一点,告诉我们你已经尝试了什么。MongoDB查询必须做什么?我正在尝试获取列表中不包含的所有对象,数组$nin if中的列表!空$profile['answered']$filter[''u id']['$nin'][]=$profile['answered'];如果空$profile['errowresponsed']$filter[''u id']['$nin']=$profile['errowresponsed']$object=$this->mongo->questions->find$filter->limit1->sort array'gallery.0'=>-1;