PMA_DBI_get_definition()

This commit is contained in:
Marc Delisle
2008-02-26 13:17:22 +00:00
parent 2ffa06dfd6
commit 4bb9cdf1b3
4 changed files with 17 additions and 28 deletions

View File

@@ -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() * @uses PMA_DBI_fetch_value()
* @param string $db db name * @param string $db db name
* @param string $which PROCEDURE | FUNCTION * @param string $which PROCEDURE | FUNCTION | EVENT
* @param string $proc_or_function_name the procedure name or function name * @param string $name the procedure|function|event name
* @param resource $link mysql link * @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'); $returned_field = array(
$query = 'SHOW CREATE ' . $which . ' ' . PMA_backquote($db) . '.' . PMA_backquote($proc_or_function_name); '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])); 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 * returns details about the TRIGGERs of a specific table

View File

@@ -28,10 +28,10 @@ if ($events) {
// information_schema (at least in MySQL 5.1.22) does not return // 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 // 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" $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"; . "\n";
$sqlDrop = 'DROP EVENT ' . PMA_backquote($event['EVENT_NAME']); $sqlDrop = 'DROP EVENT ' . PMA_backquote($event['EVENT_NAME']);

View File

@@ -40,11 +40,11 @@ if ($routines) {
// information_schema (at least in MySQL 5.0.45) // information_schema (at least in MySQL 5.0.45)
// does not return the routine parameters // 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 // uses SHOW CREATE
$definition = 'DROP ' . $routine['ROUTINE_TYPE'] . ' ' . PMA_backquote($routine['SPECIFIC_NAME']) . $delimiter . "\n" $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"; . "\n";
//if ($routine['ROUTINE_TYPE'] == 'PROCEDURE') { //if ($routine['ROUTINE_TYPE'] == 'PROCEDURE') {

View File

@@ -324,7 +324,7 @@ function PMA_exportDBFooter($db)
. PMA_exportComment(); . PMA_exportComment();
foreach($procedure_names as $procedure_name) { 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(); . PMA_exportComment();
foreach($function_names as $function_name) { 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;
} }
} }