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.
MongoDB::listCollections
(PECL mongo >=0.9.0)
MongoDB::listCollections — このデータベース内のコレクション一覧を取得する
説明
public array MongoDB::listCollections
( void
)
パラメータ
この関数にはパラメータはありません。
返り値
MongoCollection の一覧を返します。
例
例1 MongoDB::listCollections() の例
次の例は、データベース内の各コレクションを削除します。
<?php
$m = new Mongo();
$db = $m->selectDB("sample");
$list = $db->listCollections();
foreach ($list as $collection) {
echo "removing $collection... ";
$collection->drop();
echo "gone\n";
}
?>
上の例の出力は、 たとえば以下のようになります。
removing sample.blog.posts... gone removing sample.critical.docs... gone removing sample.taxes... gone ...
Matt Saunders
11-Jan-2010 01:11
