|
MongoCollection::aggregateCursorExecute an aggregation pipeline command and retrieve results through a cursor Description
public MongoCommandCursor MongoCollection::aggregateCursor
( array
$command
[, array $options
] )With this method you can execute Aggregation Framework pipelines and retrieve the results through a cursor, instead of getting just one document back as you would with MongoCollection::aggregate. This method returns a MongoCommandCursor object. This cursor object implements the Iterator interface just like the MongoCursor objects that are returned by the MongoCollection::find method.
Parameters
Return ValuesReturns a MongoCommandCursor object. Because this implements the Iterator interface you can iterate over each of the results as returned by the command query. The MongoCommandCursor also implements the MongoCursorInterface interface which adds the MongoCommandCursor::batchSize, MongoCommandCursor::dead, MongoCommandCursor::info methods. ExamplesExample #1 MongoCollection::aggregateCursor example Finding all of the distinct values for a key.
<?php The above example will output something similar to: Molly: 130 Joe: 26 Sally: 22 Example #2 MongoCollection::aggregateCursor example with different initial batch size Finding all of the distinct values for a key.
<?php The above example will output something similar to: Molly: 130 Joe: 26 Sally: 22 See Also
|