1
$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);

I am using 3.6 version of mongodb and 5.6 of PHP. the same query I am running in mongodb shell, there it is working but in php it is occuring error.

Below is the complete error:

Fatal error: Uncaught exception 'MongoResultException' with message 'localhost:27017: The 'cursor' option is required, except for aggregate with the explain argument'

Claudio
  • 5,078
  • 1
  • 22
  • 33
  • I also facing same problem here. This question is not duplicated. Already answered question is different than this . please answer to this question – Piusha May 06 '18 at 07:06

0 Answers0