MongoDB::listCollections

Gets an array of all MongoCollections for this database

&reftitle.description; public `array` `MongoDB::listCollections` `bool` `includeSystemCollections` false

Gets a list of all the collections in the database and returns them as an array of `MongoCollection` objects.

&reftitle.parameters;

`includeSystemCollections`

- Include system collections.

&reftitle.returnvalues;

Returns an array of MongoCollection objects.

&reftitle.changelog;

&Version; | &Description;
1.3.0 | Added the `includeSystemCollections` parameter.

&reftitle.examples;

### `MongoDB::listCollections` example

The following example demonstrates dropping each collection in a database.

    <?php

    $m = new MongoClient();
    $db = $m->selectDB("sample");

    $list = $db->listCollections();
    foreach ($list as $collection) {
        echo "removing $collection... ";
        $collection->drop();
        echo "gone\n";
    }

    ?>

&example.outputs.similar;

    removing sample.blog.posts... gone
    removing sample.critical.docs... gone
    removing sample.taxes... gone
    ...

&reftitle.seealso;

- `MongoDB::getCollectionNames`