function backup_migrate_source_db_mysql::_restore_db_from_file in Backup and Migrate 6.3
Same name and namespace in other branches
- 8.3 includes/sources.db.mysql.inc \backup_migrate_source_db_mysql::_restore_db_from_file()
- 7.3 includes/sources.db.mysql.inc \backup_migrate_source_db_mysql::_restore_db_from_file()
Backup the databases to a file.
Overrides backup_migrate_source_db::_restore_db_from_file
File
- includes/
sources.db.mysql.inc, line 173 - Functions to handle the direct to database source.
Class
- backup_migrate_source_db_mysql
- A source type for backing up from database server.
Code
function _restore_db_from_file($file, $settings) {
$num = 0;
if ($file
->open()) {
// Read one line at a time and run the query.
while ($line = $this
->_read_sql_command_from_file($file)) {
if (_backup_migrate_check_timeout()) {
return FALSE;
}
if ($line) {
// Use the helper instead of the api function to avoid substitution of '{' etc.
_db_query($line);
$num++;
}
}
// Close the file with fclose/gzclose.
$file
->close();
}
else {
drupal_set_message(t("Unable to open file %file to restore database", array(
"%file" => $file
->filepath(),
)), 'error');
$num = FALSE;
}
return $num;
}