From 4bb9cdf1b38c73d044f0fb8e47872d0a431e3c2b Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Tue, 26 Feb 2008 13:17:22 +0000 Subject: [PATCH] PMA_DBI_get_definition() --- libraries/database_interface.lib.php | 33 ++++++++++------------------ libraries/db_events.inc.php | 4 ++-- libraries/db_routines.inc.php | 4 ++-- libraries/export/sql.php | 4 ++-- 4 files changed, 17 insertions(+), 28 deletions(-) diff --git a/libraries/database_interface.lib.php b/libraries/database_interface.lib.php index 4c2aa4fcf..68c51c7ca 100644 --- a/libraries/database_interface.lib.php +++ b/libraries/database_interface.lib.php @@ -1207,37 +1207,26 @@ function PMA_DBI_get_procedures_or_functions($db, $which, $link = null) } /** - * returns the definition of a specific PROCEDURE or FUNCTION + * returns the definition of a specific PROCEDURE, FUNCTION or EVENT * * @uses PMA_DBI_fetch_value() * @param string $db db name - * @param string $which PROCEDURE | FUNCTION - * @param string $proc_or_function_name the procedure name or function name + * @param string $which PROCEDURE | FUNCTION | EVENT + * @param string $name the procedure|function|event name * @param resource $link mysql link * - * @return string the procedure's or function's definition + * @return string the definition */ -function PMA_DBI_get_procedure_or_function_def($db, $which, $proc_or_function_name, $link = null) +function PMA_DBI_get_definition($db, $which, $name, $link = null) { - $returned_field = array('PROCEDURE' => 'Create Procedure', 'FUNCTION' => 'Create Function'); - $query = 'SHOW CREATE ' . $which . ' ' . PMA_backquote($db) . '.' . PMA_backquote($proc_or_function_name); + $returned_field = array( + 'PROCEDURE' => 'Create Procedure', + 'FUNCTION' => 'Create Function', + 'EVENT' => 'Create Event' + ); + $query = 'SHOW CREATE ' . $which . ' ' . PMA_backquote($db) . '.' . PMA_backquote($name); return(PMA_DBI_fetch_value($query, 0, $returned_field[$which])); } -/** - * returns the definition of a specific EVENT - * - * @uses PMA_DBI_fetch_value() - * @param string $db db name - * @param string $event_name - * @param resource $link mysql link - * - * @return string the event's definition - */ -function PMA_DBI_get_event_def($db, $event_name, $link = null) -{ - $query = 'SHOW CREATE EVENT' . ' ' . PMA_backquote($db) . '.' . PMA_backquote($event_name); - return(PMA_DBI_fetch_value($query, 0, 'Create Event')); -} /** * returns details about the TRIGGERs of a specific table diff --git a/libraries/db_events.inc.php b/libraries/db_events.inc.php index 8d9a8421c..0c1693e32 100644 --- a/libraries/db_events.inc.php +++ b/libraries/db_events.inc.php @@ -28,10 +28,10 @@ if ($events) { // information_schema (at least in MySQL 5.1.22) does not return // the full CREATE EVENT statement in a way that could be useful for us - // so we rely on PMA_DBI_get_event_def() which uses SHOW CREATE EVENT + // so we rely on PMA_DBI_get_definition() which uses SHOW CREATE EVENT $definition = 'DROP EVENT ' . PMA_backquote($event['EVENT_NAME']) . $delimiter . "\n" - . PMA_DBI_get_event_def($db, $event['EVENT_NAME']) + . PMA_DBI_get_definition($db, 'EVENT', $event['EVENT_NAME']) . "\n"; $sqlDrop = 'DROP EVENT ' . PMA_backquote($event['EVENT_NAME']); diff --git a/libraries/db_routines.inc.php b/libraries/db_routines.inc.php index 48c471a77..b4796e8d9 100644 --- a/libraries/db_routines.inc.php +++ b/libraries/db_routines.inc.php @@ -40,11 +40,11 @@ if ($routines) { // information_schema (at least in MySQL 5.0.45) // does not return the routine parameters - // so we rely on PMA_DBI_get_procedure_or_function_def() which + // so we rely on PMA_DBI_get_definition() which // uses SHOW CREATE $definition = 'DROP ' . $routine['ROUTINE_TYPE'] . ' ' . PMA_backquote($routine['SPECIFIC_NAME']) . $delimiter . "\n" - . PMA_DBI_get_procedure_or_function_def($db, $routine['ROUTINE_TYPE'], $routine['SPECIFIC_NAME']) + . PMA_DBI_get_definition($db, $routine['ROUTINE_TYPE'], $routine['SPECIFIC_NAME']) . "\n"; //if ($routine['ROUTINE_TYPE'] == 'PROCEDURE') { diff --git a/libraries/export/sql.php b/libraries/export/sql.php index dad2d8bc5..7518d028a 100644 --- a/libraries/export/sql.php +++ b/libraries/export/sql.php @@ -324,7 +324,7 @@ function PMA_exportDBFooter($db) . PMA_exportComment(); foreach($procedure_names as $procedure_name) { - $procs_funcs .= PMA_DBI_get_procedure_or_function_def($db, 'PROCEDURE', $procedure_name) . $delimiter . $crlf . $crlf; + $procs_funcs .= PMA_DBI_get_definition($db, 'PROCEDURE', $procedure_name) . $delimiter . $crlf . $crlf; } } @@ -335,7 +335,7 @@ function PMA_exportDBFooter($db) . PMA_exportComment(); foreach($function_names as $function_name) { - $procs_funcs .= PMA_DBI_get_procedure_or_function_def($db, 'FUNCTION', $function_name) . $delimiter . $crlf . $crlf; + $procs_funcs .= PMA_DBI_get_definition($db, 'FUNCTION', $function_name) . $delimiter . $crlf . $crlf; } }