【发布时间】:2015-12-12 12:48:03
【问题描述】:
您好,我需要有关 php 和 mongo db 的帮助。 我的服务器中有这样的文档:
comment: "aaaaaa"
id: "11111"
_id: {$id: "564c5a297efcf0181d00002c"}
active: true
flag: 7
我需要给它一些 id
$ids = "5555,3333,2222,11111"
我需要在我的文档中搜索具有此 ID 的所有结果 我这样做:
$query = array("id" => array('$in'=> $where));
它工作正常,但现在我需要添加另一个条件。
我需要在我的文档中找到所有的 id,但那个也有
"active" => true,
"comment.length" > 2
所以 rusult 查询将给我所有具有 id && active = true && comment.length > 2 之一的文档 我设法找到了 active 和 comment.length 的解决方案:
$jsCond = "function() {
return this.comment.length > 2 && this.active == true ;
}";
但是不知道如何让它运作良好。
我需要帮助!!谢谢!
【问题讨论】:
标签: php arrays mongodb mongodb-query