MongoCollection::__construct
MongoCollection::createDBRef
MongoCollection
PHP Manual

# MongoCollection::count

(PECL mongo >=0.9.0)

MongoCollection::count — Counts the number of documents in this collection

### Descrição

public int MongoCollection::count ([ mixed `$query` = array() ] )

### Parâmetros

`query`

  Array or object with fields to match.

### Valor Retornado

Returns the number of documents matching the query.

### Exemplos

Exemplo #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)));
?>`

O exemplo acima irá imprimir algo similar a:

    int(3)
    int(1)

MongoCollection::__construct
MongoCollection::createDBRef
MongoCollection
PHP Manual