MongoDB
PHP Manual

MongoDB::listCollections

(PECL mongo >=0.9.0)

MongoDB::listCollectionsGets an array of all MongoCollections for this database

Descrizione

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.

Elenco dei parametri

includeSystemCollections

Include system collections.

Valori restituiti

Returns an array of MongoCollection objects.

Log delle modifiche

Versione Descrizione
1.3.0 Added the includeSystemCollections parameter.

Esempi

Example #1 MongoDB::listCollections() example

The following example demonstrates running count on each collection in a database.

<?php

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

$list $db->listCollections();
foreach (
$list as $collection) {
    echo 
"amount of documents in $collection: ";
    echo 
$collection->count(), "\n";
}

?>

Il precedente esempio visualizzerĂ  qualcosa simile a:

...
amount of documents in demo.pubs: 4
amount of documents in demo.elephpants: 3
amount of documents in demo.cities: 22840
...

Vedere anche:


MongoDB
PHP Manual