As part of Symfony Doctrine, I use MongoDB as a database. I need to have a list of all the collections in the database.
I thought the ListCollections() method would give me this, as the name suggests and the documentation. Except that this function does not return me anything.
From Symfony PHP, I call the method as follows:
$this->get('doctrine_mongodb.odm.default_connection')->selectDatabase('database');
This gives me an instance of the Doctrine\MongoDB\Database class. This class has a listCollection() function, as follows:
public function listCollections() { return $this->mongoDB->listCollections(); }
Since the documentation assumes that this function should return the array it makes (but it is empty even if there are collections in my database).
So, I went deeper and looked at the ListCollections() documentation of the ListCollections() pecl plugin, which says:
public function listCollections($includeSystemCollections = false) {}
How to get all collection names in one database in Symfony 3.0.6?
Some important details:
- Mongo version: 1.5.5
- Symfony Version: 3.0.6
- MongoDB Shell Version: 3.2.4
source share