(PECL mongo >=0.9.0)
MongoDB::listCollections — Get a list of collections in this database
Diese Funktion hat keine Parameter.
Returns a list of MongoCollections.
Beispiel #1 MongoDB::listCollections() example
The following example demonstrates dropping each collection in a database.
<?php
$m = new Mongo();
$db = $m->selectDB("sample");
$list = $db->listCollections();
foreach ($list as $collection) {
echo "removing $collection... ";
$collection->drop();
echo "gone\n";
}
?>
Das oben gezeigte Beispiel erzeugt eine ähnliche Ausgabe wie:
removing sample.blog.posts... gone removing sample.critical.docs... gone removing sample.taxes... gone ...
Currently, the PHP equivalent to "show dbs" is:
$db->command(array("listDatabases" => 1));
According to kristina1 in #mongodb, there will be a proper helper (listDatabases() I presume ) for this command in a later version.