1 backup.mysql.inc | protected BackupMySql::restoreDatabaseFromFile(BackupFile $file) |
Backup the databases to a file.
Return value
int|false: The number of commands executed on restore. FALSE on failure.
Overrides BackupDatabase::restoreDatabaseFromFile
File
- core/
includes/ backup/ backup.mysql.inc, line 130 - Contains the BackupMySQL class.
Class
- BackupMySql
- Creates and restores backups from a MySQL database source.
Code
protected function restoreDatabaseFromFile(BackupFile $file) {
$lines_executed = 0;
if ($file->open() && $connection = $this->getDatabaseConnection()) {
// Read one line at a time and run the query.
while ($line = $this->readSqlCommandFromFile($file)) {
if ($this->timeoutCheck()) {
return FALSE;
}
// Prepare and execute the statement instead of the api function to
// avoid substitution of '{' etc.
$statement = $connection->prepare($line);
$statement->execute();
$lines_executed++;
}
// Close the file with fclose/gzclose.
$file->close();
}
else {
backdrop_set_message(t('Unable to open file %file to restore database', array('%file' => $file->filepath())), 'error');
return FALSE;
}
return $lines_executed;
}