1 backup.mysql.inc | protected BackupMySql::getViewCreateSql($view) |
Get the SQL for the structure of the given view.
File
- core/
includes/ backup/ backup.mysql.inc, line 300 - Contains the BackupMySQL class.
Class
- BackupMySql
- Creates and restores backups from a MySQL database source.
Code
protected function getViewCreateSql($view) {
$out = '';
// Switch SQL mode to get rid of "CREATE ALGORITHM..." what requires more
// permissions + troubles with the DEFINER user.
$sql_mode = $this->query("SELECT @@SESSION.sql_mode")->fetchField();
$this->query("SET sql_mode = 'ANSI'");
$result = $this->query("SHOW CREATE VIEW `" . $view['name'] . "`", array(), array('fetch' => PDO::FETCH_ASSOC));
$this->query("SET SQL_mode = :mode", array(':mode' => $sql_mode));
foreach ($result as $create) {
$out .= "DROP VIEW IF EXISTS `" . $view['name'] . "`;\n";
$out .= "SET sql_mode = 'ANSI';\n";
$out .= strtr($create['Create View'], "\n", " ") . ";\n";
$out .= "SET sql_mode = '$sql_mode';\n";
}
return $out;
}