Symfony Doctrine内で私はデータベースとしてMongoDBを使用しています。私はデータベース内のすべてのコレクションのリストを持っている必要があります。MongoDB :: listCollections not working
私は方法ListCollections()
が私にこれらの名前とドキュメントが示唆するものと思った。 この機能以外は何も返されません。 symfonyのPHPから私はこのようなメソッドを呼んでいる
:
/**
* Wrapper method for MongoDB::listCollections().
*
* @see http://php.net/manual/en/mongodb.listcollections.php
* @return array
*/
public function listCollections()
{
return $this->mongoDB->listCollections();
}
:
$this->get('doctrine_mongodb.odm.default_connection')->selectDatabase('database');
これは私のクラスこのクラスは、機能listCollection()
を持ってDoctrine\MongoDB\Database
のインスタンスを与えるには、後述するように
ドキュメンテーションによれば、この関数はそれが行う配列を返さなければならないと示唆しています(それでも、データベースにコレクションがある場合でもそれは空です)。
は、だから私は深く移動と状態のmongo PECLプラグインのlistCollections()
のドキュメントを見て:
/**
* (PECL mongo >= 0.9.0)<br/>
* Get a list of collections in this database
* @link http://www.php.net/manual/en/mongodb.listcollections.php
* @param bool $includeSystemCollections [optional] <p>Include system collections.</p>
* @return array Returns a list of MongoCollections.
*/
public function listCollections($includeSystemCollections = false) {}
どのようにしてsymfonyの3.0.6内のデータベース内のすべてのコレクション名を取得するのでしょうか?
いくつかの重要な詳細:
- モンゴバージョン:1.5.5
- symfonyのバージョン:3.0.6
- のMongoDBシェルバージョン:3.2.4