MongoCollection::__construct
MongoCollection::createDBRef
MongoCollection
PHP Manual

# MongoCollection::count

(PECL mongo >=0.9.0)

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

### Opis

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

### Parametry

`query`

  Only count documents matching this query.

`fields`

  Only count documents with these fields.

### Zwracane wartości

Returns the number of documents.

### Przykłady

Przykład #1 MongoCollection::count() example

`<?php
$collection->insert(array('x'=>1));
$collection->insert(array('x'=>2));
$collection->insert(array('x'=>3, 'y'=>1));
var_dump($collection->count());
var_dump($collection->count(array('x'=>1)));
var_dump($collection->count(array(), array('z'=>1)));
?>`

Powyższy przykład wyświetli coś podobnego do:

    int(3)
    int(1)
    int(0)

MongoCollection::__construct
MongoCollection::createDBRef
MongoCollection
PHP Manual