diff --git a/libraries/export.lib.php b/libraries/export.lib.php index a8c598cf87..b0b05041da 100644 --- a/libraries/export.lib.php +++ b/libraries/export.lib.php @@ -662,6 +662,13 @@ function PMA_exportDatabase( if (! $export_plugin->exportDBFooter($db, $db_alias)) { return; } + + if (($GLOBALS['sql_structure_or_data'] == 'structure' + || $GLOBALS['sql_structure_or_data'] == 'structure_and_data') + && isset($GLOBALS['sql_procedure_function']) + ) { + $export_plugin->exportEvents($db, $aliases); + } } /** diff --git a/libraries/plugins/ExportPlugin.class.php b/libraries/plugins/ExportPlugin.class.php index 70f875048a..b74cd66640 100644 --- a/libraries/plugins/ExportPlugin.class.php +++ b/libraries/plugins/ExportPlugin.class.php @@ -109,6 +109,19 @@ abstract class ExportPlugin ; } + /** + * Exports events + * + * @param string $db Database + * @param array $aliases Aliases of db/table/columns + * + * @return bool Whether it succeeded + */ + public function exportEvents($db, $aliases = array()) + { + ; + } + /** * Outputs table's structure * diff --git a/libraries/plugins/export/ExportSql.class.php b/libraries/plugins/export/ExportSql.class.php index eb335f3d83..123950b953 100644 --- a/libraries/plugins/export/ExportSql.class.php +++ b/libraries/plugins/export/ExportSql.class.php @@ -887,50 +887,58 @@ class ExportSql extends ExportPlugin unset($GLOBALS['sql_constraints']); } - if (($GLOBALS['sql_structure_or_data'] == 'structure' - || $GLOBALS['sql_structure_or_data'] == 'structure_and_data') - && isset($GLOBALS['sql_procedure_function']) - ) { - $text = ''; - $delimiter = '$$'; - - $event_names = $GLOBALS['dbi']->fetchResult( - 'SELECT EVENT_NAME FROM information_schema.EVENTS WHERE' - . ' EVENT_SCHEMA= \'' - . PMA_Util::sqlAddSlashes($db, true) - . '\';' - ); - - if ($event_names) { - $text .= $crlf - . 'DELIMITER ' . $delimiter . $crlf; - - $text .= - $this->_exportComment() - . $this->_exportComment(__('Events')) - . $this->_exportComment(); - - foreach ($event_names as $event_name) { - if (! empty($GLOBALS['sql_drop_table'])) { - $text .= 'DROP EVENT ' - . PMA_Util::backquote($event_name) - . $delimiter . $crlf; - } - $text .= $GLOBALS['dbi'] - ->getDefinition($db, 'EVENT', $event_name) - . $delimiter . $crlf . $crlf; - } - - $text .= 'DELIMITER ;' . $crlf; - } - - if (! empty($text)) { - $result = PMA_exportOutputHandler($text); - } - } return $result; } + /** + * Exports events + * + * @param string $db Database + * @param array $aliases Aliases of db/table/columns + * + * @return bool Whether it succeeded + */ + public function exportEvents($db, $aliases = array()) + { + global $crlf; + + $text = ''; + $delimiter = '$$'; + + $event_names = $GLOBALS['dbi']->fetchResult( + "SELECT EVENT_NAME FROM information_schema.EVENTS WHERE" + . " EVENT_SCHEMA= '" . PMA_Util::sqlAddSlashes($db, true) . "';" + ); + + if ($event_names) { + $text .= $crlf + . "DELIMITER " . $delimiter . $crlf; + + $text .= + $this->_exportComment() + . $this->_exportComment(__('Events')) + . $this->_exportComment(); + + foreach ($event_names as $event_name) { + if (! empty($GLOBALS['sql_drop_table'])) { + $text .= "DROP EVENT " + . PMA_Util::backquote($event_name) + . $delimiter . $crlf; + } + $text .= $GLOBALS['dbi']->getDefinition($db, 'EVENT', $event_name) + . $delimiter . $crlf . $crlf; + } + + $text .= "DELIMITER ;" . $crlf; + } + + if (! empty($text)) { + return PMA_exportOutputHandler($text); + } else { + return false; + } + } + /** * Returns a stand-in CREATE definition to resolve view dependencies *