$myCollection = $con->Database_name->Collection1;
$ops = array(
array(
"$lookup" => array(
"from" => "Collection2",
"localField" => "Collection1.field",
"foreignField" => "Collection2.field",
"as" => "Name of Alias"
)
)
);
$results = $myCollection->aggregate($ops);
var_dump($results);
我使用的是mongodb的3.6版本和PHP的5.6版本。我在mongodb shell中运行的相同查询,它正在工作,但在php中它出现了错误。
以下是完整的错误:
致命错误:未捕获的异常' MongoResultException'消息' localhost:27017:'光标'选项是必需的,但带有explain参数'
的聚合除外