Hi there,I am fiddeling since hours with no result to retrieve a list of collections. Probably I am overlooking something here.$manager = new \MongoDB\Driver\Manager($host);$cmd = new \MongoDB\Driver\Command(['listCollections' => 1]);$res = $manager->executeCommand($db_name, $cmd);This gives an error that listCollections is no command but it is listed here. The listCommand (which works) on the other hand doesnt show it.
https://docs.mongodb.com/manual/reference/command/Should I have to do it differently? The same code with listDatabases works perfectly.I am using the latest driver for PHP 7.1 on windows that connects to a 2.6 DB on debian.Any hints on this?
By the way I am not very happy with the general usage of Objects in the driver - they are hard to use and often very confusing.Associative arrays as defaults are way easier to handle in my opinion.
--- Johannes
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
For other MongoDB technical support options, see: https://docs.mongodb.com/manual/support/
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user+unsubscribe@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/a968be96-73dd-4099-b54c-10484d84d004%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
On Wed, Mar 29, 2017 at 11:15 AM, 'Johannes Reichardt' via mongodb-user <mongod...@googlegroups.com> wrote:Hi there,I am fiddeling since hours with no result to retrieve a list of collections. Probably I am overlooking something here.$manager = new \MongoDB\Driver\Manager($host);$cmd = new \MongoDB\Driver\Command(['listCollections' => 1]);$res = $manager->executeCommand($db_name, $cmd);This gives an error that listCollections is no command but it is listed here. The listCommand (which works) on the other hand doesnt show it.
https://docs.mongodb.com/manual/reference/command/Should I have to do it differently? The same code with listDatabases works perfectly.I am using the latest driver for PHP 7.1 on windows that connects to a 2.6 DB on debian.Any hints on this?The listCollections command was only introduced in MongoDB 3.0. Earlier versions of the database require you to run a query on the system.namespaces collection. In addition to the extension, we suggest that folks also use the PHP library, which implements many of the high-level APIs found in the old extension. In this case, you could utilize the library's MongoDB\Database::listCollections() method without worrying about different server versions. If you are curious about how we handle differing server versions, you can take a look at the MongoDB\Operation\ListCollections implementation.By the way I am not very happy with the general usage of Objects in the driver - they are hard to use and often very confusing.Associative arrays as defaults are way easier to handle in my opinion.The reasons for the new driver's default behavior is discussed here. Note that in the library, we default to returning BSONDocument and BSONArray classes for BSON documents and arrays, respectively. Those classes both extend PHP's ArrayObject type and allow you to use array access operators, unlike the stdClass instances returned by the raw driver. In the linked article, we also demonstrate how to configure the library to emulate the legacy driver and return PHP arrays for BSON documents and arrays if desired.
- Johannes
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
For other MongoDB technical support options, see: https://docs.mongodb.com/manual/support/
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
Thank you for the insight. I already felt that it has to do with the DB version.I don't fully understand the problems regarding objects for data
These problems are not unique to the MongoDB driver. You'll find that json_encode() has the same challenge.
but I still do not see a point in returning information like names of indexes as an object by default (posted another question about this before I read your reply).
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user+unsubscribe@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/e1b48fc1-cd93-4953-b99a-6b21a9a359e7%40googlegroups.com.