MongoCollection::count

Counts the number of documents in this collection

&reftitle.description; public `int` `MongoCollection::count` `array` `query` array() `int` `limit` 0 `int` `skip` 0
&reftitle.parameters;

`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.

&reftitle.returnvalues;

Returns the number of documents matching the query.

&reftitle.changelog;

&Version; | &Description;
1.0.7 | Added `limit` and `skip` parameters.

&reftitle.examples;

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

    ?>

&example.outputs.similar;

    int(3)
    int(1)