这是示例代码:PHP MongoDB的驱动程序,获取数据,然后将其删除,不工作
$r = $coll->findOne();
$coll->remove(array("_id"=>$r["_id"])); // use the same object id as retreived from DB
$ret=$coll->findOne(array("_id"=>($r["_id"])));
var_dump($ret); // dumps the records that was supposed to be deleted
集合中的记录有MongoDB的对象ID,而不是字符串。 控制台上的相同逻辑正常工作并正确删除记录。