Php 聚合后集合名称已设置为空

Php 聚合后集合名称已设置为空,php,mongodb,match,Php,Mongodb,Match,我尝试连接到mongodb,如下所示 $mongo = new \MongoDB\Client(); $db = $mongo->selectCollection("tourism","users"); 当我使用$db变量查找或插入其他函数(与下面的代码相同)时,这是可以的 但当我尝试使用聚合时,集合名称被设置为null object(MongoDB\Driver\Cursor)[66] public 'database' => string 'tourism' (length=

我尝试连接到mongodb,如下所示

$mongo = new \MongoDB\Client();
$db = $mongo->selectCollection("tourism","users"); 
当我使用$db变量查找或插入其他函数(与下面的代码相同)时,这是可以的

但当我尝试使用聚合时,集合名称被设置为null

object(MongoDB\Driver\Cursor)[66]
public 'database' => string 'tourism' (length=7)
public 'collection' => null
这是我用PHP编写的完整代码

$mongo = new \MongoDB\Client();
$db = $mongo->selectCollection("tourism","users");
$ops = [['$match'=>['key'=>'09216604502']]];
$results = $db->aggregate($ops);
exit(var_dump($results));
$db = $mongo->selectCollection("tourism","languages");
$ops = [['$match'=>['code'=>'fa']]];
$results = $db->aggregate($ops);
$results = current($results->toArray());
我发现了那个问题。 使用聚合集合时,集合名称应为null,并将填充管道变量

在执行聚合命令之后,我们应该用下面的PHP代码将其转换为数组

$mongo = new \MongoDB\Client();
$db = $mongo->selectCollection("tourism","users");
$ops = [['$match'=>['key'=>'09216604502']]];
$results = $db->aggregate($ops);
exit(var_dump($results));
$db = $mongo->selectCollection("tourism","languages");
$ops = [['$match'=>['code'=>'fa']]];
$results = $db->aggregate($ops);
$results = current($results->toArray());

请向我们显示您正在运行的代码,否则我们无法帮助您。post edited;)谢谢