From 5d0c2032ce741f3c59cc7bd1ca4f09d9f30fbf6d Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Wed, 27 Feb 2008 18:00:30 +0000 Subject: [PATCH] Export events --- ChangeLog | 5 +++-- libraries/export/sql.php | 40 ++++++++++++++++++++++++++++------------ 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 26debd989..0f79ae360 100644 --- a/ChangeLog +++ b/ChangeLog @@ -41,8 +41,9 @@ $HeadURL: https://phpmyadmin.svn.sourceforge.net/svnroot/phpmyadmin/trunk/phpMyA + [lang] Norwegian update, thanks to Sven-Erik Andersen + [lang] Japanese update, thanks to Ishigaki Kenichi + [lang] Italian update, thanks to Luca Rebellato -+ [gui] Events management: minimal support on db structure page - (work in progress) ++ [gui] Events (work in progress) + * minimal support on db structure page + * export 2.11.5.0 (not yet released) - bug #1862661 [GUI] Warn about rename deleting database diff --git a/libraries/export/sql.php b/libraries/export/sql.php index 7518d028a..125a9536a 100644 --- a/libraries/export/sql.php +++ b/libraries/export/sql.php @@ -71,7 +71,7 @@ if (isset($plugin_list)) { $plugin_list['sql']['options'][] = array('type' => 'bool', 'name' => 'backquotes', 'text' => 'strUseBackquotes'); $plugin_list['sql']['options'][] = - array('type' => 'bool', 'name' => 'procedure_function', 'text' => sprintf($GLOBALS['strAddClause'], 'CREATE PROCEDURE / FUNCTION')); + array('type' => 'bool', 'name' => 'procedure_function', 'text' => sprintf($GLOBALS['strAddClause'], 'CREATE PROCEDURE / FUNCTION' . (PMA_MYSQL_INT_VERSION > 50100 ? ' / EVENT' : ''))); /* MIME stuff etc. */ $plugin_list['sql']['options'][] = @@ -306,45 +306,61 @@ function PMA_exportDBFooter($db) } if (isset($GLOBALS['sql_structure']) && isset($GLOBALS['sql_procedure_function'])) { - $procs_funcs = ''; + $text = ''; $delimiter = '$$'; $procedure_names = PMA_DBI_get_procedures_or_functions($db, 'PROCEDURE'); $function_names = PMA_DBI_get_procedures_or_functions($db, 'FUNCTION'); - if ($procedure_names || $function_names) { - $procs_funcs .= $crlf + if (PMA_MYSQL_INT_VERSION > 50100) { + $event_names = PMA_DBI_fetch_result('SELECT EVENT_NAME FROM information_schema.EVENTS WHERE EVENT_SCHEMA= \'' . PMA_sqlAddslashes($db,true) . '\';'); + } else { + $event_names = array(); + } + + if ($procedure_names || $function_names || $event_names) { + $text .= $crlf . 'DELIMITER ' . $delimiter . $crlf; } if ($procedure_names) { - $procs_funcs .= + $text .= PMA_exportComment() . PMA_exportComment($GLOBALS['strProcedures']) . PMA_exportComment(); foreach($procedure_names as $procedure_name) { - $procs_funcs .= PMA_DBI_get_definition($db, 'PROCEDURE', $procedure_name) . $delimiter . $crlf . $crlf; + $text .= PMA_DBI_get_definition($db, 'PROCEDURE', $procedure_name) . $delimiter . $crlf . $crlf; } } if ($function_names) { - $procs_funcs .= + $text .= PMA_exportComment() . PMA_exportComment($GLOBALS['strFunctions']) . PMA_exportComment(); foreach($function_names as $function_name) { - $procs_funcs .= PMA_DBI_get_definition($db, 'FUNCTION', $function_name) . $delimiter . $crlf . $crlf; + $text .= PMA_DBI_get_definition($db, 'FUNCTION', $function_name) . $delimiter . $crlf . $crlf; } } - if ($procedure_names || $function_names) { - $procs_funcs .= 'DELIMITER ;' . $crlf; + if ($event_names) { + $text .= + PMA_exportComment() + . PMA_exportComment($GLOBALS['strEvents']) + . PMA_exportComment(); + + foreach($event_names as $event_name) { + $text .= PMA_DBI_get_definition($db, 'EVENT', $event_name) . $delimiter . $crlf . $crlf; + } + } + if ($procedure_names || $function_names || $event_names) { + $text .= 'DELIMITER ;' . $crlf; } - if (!empty($procs_funcs)) { - $result = PMA_exportOutputHandler($procs_funcs); + if (! empty($text)) { + $result = PMA_exportOutputHandler($text); } } return $result;