MongoDB
PHP Manual

MongoDB::getCollectionNames

(PECL mongo >=1.3.0)

MongoDB::getCollectionNamesこのデータベースのすべてのコレクションを取得する

説明

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

指定したデータベースのすべてのコレクションの名前を配列で返します。

パラメータ

includeSystemCollections

システムコレクションを含むかどうか。

返り値

指定したデータベースのすべてのコレクションの名前を配列で返します。

例1 MongoDB::getCollectionNames() の例

<?php

$m 
= new Mongo;
$collections $m->selectDB("demo")->getCollectionNames();
var_dump($collections);
?>

上の例の出力は、 たとえば以下のようになります。

array(2) {
  [0]=>
  string(9) "addresses"
  [1]=>
  string(5) "users"
}

参考


MongoDB
PHP Manual