MongoDB
PHP Manual

MongoDB::getCollectionNames

(PECL mongo >=1.3.0)

MongoDB::getCollectionNamesGet all collections from this database

Descrizione

public array MongoDB::getCollectionNames ([ bool $includeSystemCollections = false ] )

Returns an array of all the collection names for the given database.

Elenco dei parametri

includeSystemCollections

Include system collections.

Valori restituiti

Returns the names of the all the collections in the database as an array.

Esempi

Example #1 MongoDB::getCollectionNames() example

<?php
$m 
= new MongoClient;
$collections $m->selectDB("demo")->getCollectionNames();

foreach (
$collections as $collectionName) {
    echo 
"Found collection: "$collectionName"\n";
}
?>

Il precedente esempio visualizzerĂ  qualcosa simile a:

...
Found collection: img
Found collection: beer
Found collection: collation
...

Vedere anche:


MongoDB
PHP Manual