PMA_runEventDefinitionsForDb() function implementation

This commit is contained in:
Thilina Buddika 2012-07-25 02:40:43 +05:30
parent 1b7860150a
commit e8f1dacb4d
2 changed files with 27 additions and 17 deletions

View File

@ -153,23 +153,7 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) {
// here DELIMITER is not used because it's not part of the
// language; each statement is sent one by one
// to avoid selecting alternatively the current and new db
// we would need to modify the CREATE definitions to qualify
// the db name
$event_names = PMA_DBI_fetch_result(
'SELECT EVENT_NAME FROM information_schema.EVENTS WHERE EVENT_SCHEMA= \''
. $common_functions->sqlAddSlashes($db, true) . '\';'
);
if ($event_names) {
foreach ($event_names as $event_name) {
PMA_DBI_select_db($db);
$tmp_query = PMA_DBI_get_definition($db, 'EVENT', $event_name);
// collect for later display
$GLOBALS['sql_query'] .= "\n" . $tmp_query;
PMA_DBI_select_db($newname);
PMA_DBI_query($tmp_query);
}
}
PMA_runEventDefinitionsForDb();
}
// go back to current db, just in case

View File

@ -466,4 +466,30 @@ function PMA_getSqlQueryForCopyTable($tables_full, $sql_query, $move)
}
return array($sql_query, $error);
}
/**
* Run the EVENT definition for selected database
*
* to avoid selecting alternatively the current and new db
* we would need to modify the CREATE definitions to qualify
* the db name
*/
function PMA_runEventDefinitionsForDb()
{
$event_names = PMA_DBI_fetch_result(
'SELECT EVENT_NAME FROM information_schema.EVENTS WHERE EVENT_SCHEMA= \''
. $common_functions->sqlAddSlashes($GLOBALS['db'], true) . '\';'
);
if ($event_names) {
foreach ($event_names as $event_name) {
PMA_DBI_select_db($GLOBALS['db']);
$tmp_query = PMA_DBI_get_definition($GLOBALS['db'], 'EVENT', $event_name);
// collect for later display
$GLOBALS['sql_query'] .= "\n" . $tmp_query;
PMA_DBI_select_db($_REQUEST['newname']);
PMA_DBI_query($tmp_query);
}
}
}
?>