From 2cfaf8f4116c40a66d5f9a8ac7ff92fbbce6aea7 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Fri, 31 Jul 2015 12:54:51 +0530 Subject: [PATCH] Support alias Signed-off-by: Madhura Jayaratne --- libraries/plugins/export/ExportSql.class.php | 30 ++++++++++++++++++-- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/libraries/plugins/export/ExportSql.class.php b/libraries/plugins/export/ExportSql.class.php index 727565c806..e32772fa1c 100644 --- a/libraries/plugins/export/ExportSql.class.php +++ b/libraries/plugins/export/ExportSql.class.php @@ -924,6 +924,9 @@ class ExportSql extends ExportPlugin { global $crlf; + $db_alias = $db; + $this->initAlias($aliases, $db_alias); + $text = ''; $delimiter = '$$'; @@ -934,12 +937,13 @@ class ExportSql extends ExportPlugin if ($event_names) { $text .= $crlf - . "DELIMITER " . $delimiter . $crlf; + . "DELIMITER " . $delimiter . $crlf; $text .= $this->_exportComment() . $this->_exportComment(__('Events')) . $this->_exportComment(); + $used_alias = false; foreach ($event_names as $event_name) { if (! empty($GLOBALS['sql_drop_table'])) { @@ -947,8 +951,28 @@ class ExportSql extends ExportPlugin . PMA_Util::backquote($event_name) . $delimiter . $crlf; } - $text .= $GLOBALS['dbi']->getDefinition($db, 'EVENT', $event_name) - . $delimiter . $crlf . $crlf; + $create_query = $GLOBALS['dbi']->getDefinition( + $db, 'EVENT', $event_name + ); + $create_query = $this->replaceWithAliases( + $create_query, $aliases, $db, '', $flag + ); + // One warning per database + if ($flag) { + $used_alias = true; + } + $text .= $create_query . $delimiter . $crlf . $crlf;; + } + if ($used_alias) { + $text .= $this->_exportComment( + __( + 'It appears your database uses events;' + ) + ) + . $this->_exportComment( + __('alias export may not work reliably in all cases.') + ) + . $this->_exportComment(); } $text .= "DELIMITER ;" . $crlf;