我有一个来自 MongoDB 的这种形式的 JSON,我想根据相同的查询检索文档:
{
"_id" : ObjectId("5281fb3070c68c0c1ccc4f00"),
"channel" : "1",
"content" : "8578",
"duplicateOf" : null,
"id" : "7420",
"keywords" : [ObjectId("52816d3370c68c2c1c450500"), ObjectId("52816d3370c68c2c1c570500"), ObjectId("52816d3370c68c2c1c470500"), ObjectId("52816d3370c68c2c1c4d0500"), ObjectId("52816d3370c68c2c1c590500"), ObjectId("52816d3370c68c2c1c530500"), ObjectId("52816d3370c68c2c1c4f0500"), ObjectId("52816d3370c68c2c1c6b0500")],
"lastUpdate" : "2009-11-16"]
}
我将此查询与 MongoVue 一起使用,它可以工作:
db.Measurements.find({ "_id" :
{ "$in" : [ObjectId("5281fb3070c68c0c1ccc4f00"), ObjectId("5281fb3070c68c0c1cce4f00")] } })
但我找不到让它在 PHP 中工作的方法,这是代码的一部分:
foreach ($series as $doc) {
$ids = $collectionMeasurements->find(array('_id' => array($in=>new MongoId($doc[keywords]))));
}
谢谢你的帮助!!!
==================================================== === 发现错误!!!
foreach ($series as $doc) {
$ids = $collectionMeasurements->find(array('_id' => array(
'$in'=>array(new MongoId(string)($doc[keywords])))));
}