3 回答

TA貢獻(xiàn)1876條經(jīng)驗(yàn) 獲得超7個(gè)贊
據(jù)我所知,目前mongoDB沒(méi)有“或”這個(gè)東西
但我剛才在網(wǎng)上查了下
發(fā)現(xiàn)了下面的信息,你參考下吧
在mongodb中有$or 操作符的,官網(wǎng)中給出的例子如下:
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.

TA貢獻(xiàn)1851條經(jīng)驗(yàn) 獲得超5個(gè)贊
我用這樣的語(yǔ)句已經(jīng)查到了想查的結(jié)果:$query = array('$or'=>array(array("發(fā)送者"=>$_SESSION[nick],"發(fā)送對(duì)象"=>$_GET["sendto"]),array("發(fā)送者"=>$_GET["sendto"],"發(fā)送對(duì)象"=>$_SESSION[nick]))); $cursor = $collection->find($query);

TA貢獻(xiàn)1852條經(jīng)驗(yàn) 獲得超1個(gè)贊
1 2 3 4 | $where['$or'] = [ ['id' => ['lt'=>0]], ['id2' => ['lt'=>1]] ]; |
- 3 回答
- 0 關(guān)注
- 1350 瀏覽
添加回答
舉報(bào)