MongoCommandCursor::__construct
Create a new command cursor
&reftitle.description;
public MongoCommandCursor::__construct
MongoClientconnection
stringns
arraycommandarray()
Generally, you should not have to construct a
MongoCommandCursor manually, as there are helper
functions such as MongoCollection::aggregateCursor
and MongoCollection::parallelCollectionScan;
however, if the server introduces new commands that can return cursors, this
constructor will be useful in the absence of specific helper methods. You may
also consider using
MongoCommandCursor::createFromDocument.
&reftitle.parameters;
connection
Database connection.
ns
Full name of the database and collection (e.g.
"test.foo")
command
Database command.
&reftitle.returnvalues;
Returns the new cursor.
&reftitle.examples;
MongoCommandCursor example
[
'_id' => '$country_code',
'timezones' => [ '$addToSet' => '$timezone' ]
] ],
[ '$sort' => [ '_id' => 1 ] ],
];
// Construct a MongoCommandCursor object
$cursor = new MongoCommandCursor(
$m, // MongoClient object
'demo.cities', // namespace
[
'aggregate' => 'cities',
'pipeline' => $pipeline,
'cursor' => [ 'batchSize' => 0 ],
]
);
foreach($cursor as $result) {
…
}
?>
]]>
&reftitle.seealso;
MongoCommandCursor::createFromDocument
MongoCollection::aggregateCursor
MongoCollection::parallelCollectionScan