function backup_migrate_destination_db::switch_db in Backup and Migrate 6.2
Switch to the current database. Pass true to switch back to the previous db.
4 calls to backup_migrate_destination_db::switch_db()
- backup_migrate_destination_db::backup_to_file in includes/
destinations.db.inc - Backup from this source.
- backup_migrate_destination_db::get_object_names in includes/
destinations.db.inc - Get a list of objects in the database.
- backup_migrate_destination_db::get_table_names in includes/
destinations.db.inc - Get a list of tables in the database.
- backup_migrate_destination_db::restore_from_file in includes/
destinations.db.inc - Restore to this source.
File
- includes/
destinations.db.inc, line 238 - Functions to handle the direct to database destination.
Class
- backup_migrate_destination_db
- A destination type for saving to a database server.
Code
function switch_db($switch_back = FALSE) {
static $db_stack = array();
global $db_url;
// If switch back is specified, pop the previous db and activate it.
if ($switch_back && $db_stack) {
db_set_active(array_pop($db_stack));
return;
}
// If there is a valid DB URL, switch to it.
if ($url = $this
->get_location()) {
// 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[$url] = $url;
// Switch to the new db and push the old one on the stack
$db_stack[] = db_set_active($url);
}
}