1
我将MongoDB中的“Article”保存为_id整数。 当我想在php中用_id删除文章时,什么都不会发生。 我使用的代码是:无法使用PHP驱动程序删除MongoDB中的文档
$result = $db->arcitle->remove(
array("_id" =>intVal(41)),
array('safe' => true)
);
我已经使用和不使用“安全”选项,无论是作品尝试。当我回显$ result时,它是bool(true)。
任何建议非常感谢!
{ "_id" : 41,
"when" : Date(1333318420855),
"publisher" : "5",
"title" : "10 Steps To The Perfect Portfolio Website",
"raw" : "",
"preview" : "",
"thumbnail" : "",
"content" : [
"{}" ],
"tags" : null,
"votes" : 0,
"voters" : [],
"comments" : [] }
'INTVAL( 491)'与您的文档不匹配_id'字段 – Mattias 2012-04-04 09:41:37
这是一个错字,我在发布到SO时忘了清理。我改为491来测试如果没有现场匹配会发生什么。 – 2012-04-04 10:09:01
为什么你的'_id'字段不是Bson.ObjectId类型? – 2012-04-04 10:13:48