(PECL mongo >=0.9.0)
MongoCollection::count — Counts the number of documents in this collection
Associative array or object with fields to match.
Specifies an upper limit to the number returned.
Specifies a number of results to skip before starting the count.
Returns the number of documents matching the query.
Version | Description |
---|---|
1.0.7 | Added limit and skip parameters. |
Example #1 MongoCollection::count() example
<?php
$collection->insert(array('x'=>1));
$collection->insert(array('x'=>2));
$collection->insert(array('x'=>3));
var_dump($collection->count());
var_dump($collection->count(array('x'=>1)));
?>
The above example will output something similar to:
int(3) int(1)