0

我在 PHP 中有以下代码来连接到我的 MongoDB 实例:

$connection_string = "mongodb://XXXXXXX:XXXXXX@XXXXX:XXX/myDB";             
$mongo_or = new Mongo($connection_string);
$db_or = $mongo_or->selectDB("myDB");

# Pick a collection
$collection_or = $db_or->myCollection;
$findArray = array('$and' => array('user.uid' => 1, 'friend_id' => 2));
$findArray2 = array('$and' => array('user.uid' => 2, 'friend_id' => 1));
$collection_or->remove($findArray);
$collection_or->remove($findArray2);

这永远不会删除任何结果 - 即使知道内容仍然存在,它也永远不会被删除。

4

1 回答 1

0

如果您想要 $and 查询的良好结构,只需 json_decode 这个:

{
"$and" : [{
  "$or" : [{
      "civility" : 2
    }, {
      "civility" : 3
    }]
}]
}
于 2013-05-22T16:04:03.027 回答