Here's my db:
$db = new Mongo("mongodb://u:[email protected]:37068/dbname");
I want to echo a list/array of collections (the names) on the database.
How can I do that? Thanks.
Here's my db:
$db = new Mongo("mongodb://u:[email protected]:37068/dbname");
I want to echo a list/array of collections (the names) on the database.
How can I do that? Thanks.
You can use listCollections: http://php.net/manual/en/mongodb.listcollections.php
<?php
$db = new Mongo("mongodb://u:[email protected]:37068/dbname");
$list = $db->listCollections();
foreach ($list as $collection) {
echo "$collection \n";
}
?>
echo json_encode( $list ); it gave me an array of timeout errors.