MongoCollection::count
(PECL mongo >=0.9.0)
MongoCollection::count — Counts the number of documents in this collection
Описание
public int MongoCollection::count
([ array $query = array()
[, int $limit = 0
[, int $skip = 0
]]] )
Список параметров
-
query
-
Associative array or object with fields to match.
-
limit
-
Specifies an upper limit to the number returned.
-
skip
-
Specifies a number of results to skip before starting the count.
Возвращаемые значения
Returns the number of documents matching the query.
Примеры
Пример #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)));
?>
Результатом выполнения данного примера
будет что-то подобное: