MongoDB::lastError
MongoDB::prevError
MongoDB
PHP Manual

# MongoDB::listCollections

(PECL mongo >=0.9.0)

MongoDB::listCollections — Get an of MongoCollection for this database

### Opis

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.

### Parametry

`includeSystemCollections`

  Include system collections.

### Zwracane wartości

Returns an array of MongoCollections.

### Rejestr zmian

Wersja | Opis
--- | ---
1.3.0 | Added the `includeSystemCollections` parameter.

### Przykłady

Przykład #1 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";
}
?>`

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

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

MongoDB::lastError
MongoDB::prevError
MongoDB
PHP Manual