note 113044 added to mongodb.command
| From: | nanhe dot kumar at gmail dot com | Date: | Wed, 21 Aug 2013 21:41:16 +0000 |
| Subject: | note 113044 added to mongodb.command | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-196045@lists.php.net to get a copy of this message | ||
$db=new new Mongo();
Copy old_db to new_db
$responseCopy = $db->admin->command(array(
'copydb' => 1,
'fromhost' => 'localhost',
'fromdb' => 'old_db',
'todb' =>'new_db'
));
Now drop old_db
if($responseCopy['ok']==1){
$responseDrop=$db->old_db->command(array('dropDatabase' => 1));
//OR
$responseDrop =$db->old_db->drop();
}
Show Output
print_r($responseCopy);
print_r($responseDrop);
Output will be something like this
Array ( [ok] => 1 )
Array ( [dropped] => old_db [ok] => 1 )
----
Server IP: 69.147.83.199
Probable Submitter: 14.98.6.52
----
Manual Page -- http://php.net/manual/en/mongodb.command.php
Edit -- https://master.php.net/note/edit/113044
Del: integrated -- https://master.php.net/note/delete/113044/integrated
Del: useless -- https://master.php.net/note/delete/113044/useless
Del: bad code -- https://master.php.net/note/delete/113044/bad+code
Del: spam -- https://master.php.net/note/delete/113044/spam
Del: non-english -- https://master.php.net/note/delete/113044/non-english
Del: in docs -- https://master.php.net/note/delete/113044/in+docs
Del: other reasons-- https://master.php.net/note/delete/113044
Reject -- https://master.php.net/note/reject/113044
Search -- https://master.php.net/manage/user-notes.php