You will need to run at least one command in the database before creating it ...
This command can be run before you add any collections ... so that you can simply list (non-existent) collections.
<?php $connection = new Mongo(); $db = $connection->foo; $list = $db->listCollections(); foreach ($list as $collection) { echo "$collection </br>"; } ?>
Your new database will now exist until user-created collections are created.
source share