3 回答
![?](http://img1.sycdn.imooc.com/5458692c00014e9b02200220-100-100.jpg)
TA贡献1799条经验 获得超6个赞
据我所知,目前mongoDB没有“或”这个东西
但我刚才在网上查了下
发现了下面的信息,你参考下吧
在mongodb中有$or 操作符的,官网中给出的例子如下:
Simple:
db.foo.find( { $or : [ { a : 1 } , { b : 2 } ] } )
With another field
db.foo.find( { name : "bob" , $or : [ { a : 1 } , { b : 2 } ] } )
The $or operator retrieves matches for each or clause individually and eliminates duplicates when returning results. A number of $or optimizations are planned for 1.8. See this thread for details.
$or cannot be nested.
![?](http://img1.sycdn.imooc.com/54586425000103f602200220-100-100.jpg)
TA贡献1821条经验 获得超4个赞
我用这样的语句已经查到了想查的结果:$query = array('$or'=>array(array("发送者"=>$_SESSION[nick],"发送对象"=>$_GET["sendto"]),array("发送者"=>$_GET["sendto"],"发送对象"=>$_SESSION[nick]))); $cursor = $collection->find($query);
- 3 回答
- 0 关注
- 272 浏览
添加回答
举报