Check if Database exists
Closed this issue · 1 comments
fivesand commented
Hi Sam,
How can I check if a database exists?
I have tried using getDB as follows
$test = Yii::app()->mongodb->getDB('thisshouldnotexist');
print_r($test);
I get the same result if I use the same code for any existing DB:
MongoDB Object ( [w] => 1 [wtimeout] => 10000 )
Please advise
Regards,
Ron
Sammaye commented
Unfortauntely special commands are required to check database existance, here is a JS edition: https://gist.github.com/david-torres/8450526 , basically ou need to to run listdatabases() and then iterate that result for find if your database is in there.