function _backup_migrate_db_switch_db in Backup and Migrate 5.2
Same name and namespace in other branches
- 8.2 includes/db.inc \_backup_migrate_db_switch_db()
Switch to the db described by the DB URL, or back to previous if none selected.
2 calls to _backup_migrate_db_switch_db()
- backup_migrate_db_backup in includes/
db.inc - Build the database dump file. Takes a list of tables to exclude and some formatting options.
- backup_migrate_destination_db_save in includes/
destinations.db.inc - Databse save download destination callback.
File
- includes/
db.inc, line 212 - General database dump/restore code for Backup and Migrate.
Code
function _backup_migrate_db_switch_db($in_url = NULL) {
static $db_stack = array();
global $db_url;
// If no DB URL is specified, pop the previous one and set to it.
if ($in_url === NULL && $db_stack) {
db_set_active(array_pop($db_stack));
}
// If there is a valid DB URL, switch to it.
if ($in_url) {
// Make the db_url into an array if needed.
if (!is_array($db_url)) {
$db_url = array(
'default' => $db_url,
);
}
// Add the new db to the db_url array.
$db_url[$in_url] = $in_url;
// Switch to the new db and push the old one on the stack
$db_stack[] = db_set_active($in_url);
}
}