The branch, export_xml has been updated via 2fc82afc979811a542cb749329cb48e639085fb5 (commit) via bbdf4cf808e6f4cbca73081326b84510668c72f7 (commit) from 87575151eecfb372b82379e10f5d8776617993ee (commit)
- Log ----------------------------------------------------------------- commit 2fc82afc979811a542cb749329cb48e639085fb5 Author: Dieter Adriaenssens ruleant@users.sourceforge.net Date: Sat Apr 2 14:07:12 2011 +0200
rename variables to represent better what they are for
commit bbdf4cf808e6f4cbca73081326b84510668c72f7 Author: Aamir Khan systemw0rm@users.sourceforge.net Date: Sat Apr 2 13:57:02 2011 +0200
xml export : export views
-----------------------------------------------------------------------
Summary of changes: libraries/export/xml.php | 68 ++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 60 insertions(+), 8 deletions(-)
diff --git a/libraries/export/xml.php b/libraries/export/xml.php index 58e3876..ff2fdf9 100644 --- a/libraries/export/xml.php +++ b/libraries/export/xml.php @@ -75,6 +75,55 @@ function PMA_exportFooter() { }
/** + * Returns Query for CREATE TABLE Definitions + * + * @param string the SHOW CREATE TABLE query statement result + * @param string the table name + * @param string the end of line sequence + * + * @return string resulting definition + * + * @access public + */ +function PMA_getTableDef($table_def, $table_name, $crlf) { + $create_query = ''; + $create_query .= ' <pma:table name="' . $table_name . '">' . $crlf; + + $table_def = " " . $table_def; + $table_def = str_replace("\n", "\n ", $table_def); + + $create_query .= $table_def . ';' . $crlf; + $create_query .= ' </pma:table>' . $crlf; + return $create_query; +} + +/** + * Returns a Actual View Definition + * + * @param string the Database name + * @param string the SHOW CREATE TABLE query statement result + * @param string the view name + * @param string the end of line sequence + * + * @return string resulting definition + * + * @access public + */ +function PMA_getViewDef($db, $view_def, $view_name, $crlf) { + $create_query = ''; + $create_query .= ' <pma:view name="' . $view_name . '">' . $crlf; + $view_def = " " . $view_def; + $view_def = str_replace("\n", "\n ", $view_def); + + // drop database name from VIEW creation. + $create_query .= $view_def . ';' . $crlf; + $create_query = preg_replace('/' . PMA_backquote($db) . './', '', $create_query); + + $create_query .= ' </pma:view>' . $crlf; + return $create_query; +} + +/** * Outputs export header * * @return bool Whether it suceeded @@ -186,7 +235,7 @@ function PMA_exportHeader() { foreach ($tables as $table) { // Export tables and views $result = PMA_DBI_fetch_result('SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table), 0); - $tbl = $result[$table][1]; + $table_def = $result[$table][1];
$is_view = PMA_isView($db, $table);
@@ -204,13 +253,12 @@ function PMA_exportHeader() { continue; }
- $head .= ' <pma:' . $type . ' name="' . $table . '">' . $crlf; - - $tbl = " " . $tbl; - $tbl = str_replace("\n", "\n ", $tbl); - - $head .= $tbl . ';' . $crlf; - $head .= ' </pma:' . $type . '>' . $crlf; + if ($is_view && isset($GLOBALS[$what . '_export_views'])) { + $view_create[$table] = PMA_getViewDef($db, $table_def, $table, $crlf); + continue; + } + + $head .= PMA_getTableDef($table_def, $table, $crlf);
if (isset($GLOBALS[$what . '_export_triggers']) && $GLOBALS[$what . '_export_triggers']) { // Export triggers @@ -235,6 +283,10 @@ function PMA_exportHeader() { } }
+ foreach ($view_create as $view => $definition) { + $head .= $definition; + } + unset($result);
$head .= ' </pma:database>' . $crlf;
hooks/post-receive