Inform about dropped routine, trigger and view
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@1188 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
parent
54380878ca
commit
32d5b9ccb6
|
@ -275,3 +275,15 @@ function grant($grant, $privileges, $columns, $on) {
|
||||||
}
|
}
|
||||||
return queries("$grant " . preg_replace('~(GRANT OPTION)\\([^)]*\\)~', '\\1', implode("$columns, ", $privileges) . $columns) . $on);
|
return queries("$grant " . preg_replace('~(GRANT OPTION)\\([^)]*\\)~', '\\1', implode("$columns, ", $privileges) . $columns) . $on);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function drop_create($drop, $create, $location, $message_drop, $message_alter, $message_create, $name) {
|
||||||
|
if ($_POST["drop"]) {
|
||||||
|
return query_redirect($drop, $location, $message_drop, true, !$_POST["dropped"]);
|
||||||
|
}
|
||||||
|
$dropped = strlen($name) && ($_POST["dropped"] || queries($drop));
|
||||||
|
$created = queries($create);
|
||||||
|
if (!query_redirect(queries(), $location, (strlen($name) ? $message_alter : $message_create), $created, false, !$created) && $dropped) {
|
||||||
|
$_SESSION["messages"][] = $message_drop;
|
||||||
|
}
|
||||||
|
return $dropped;
|
||||||
|
}
|
||||||
|
|
|
@ -4,10 +4,6 @@ $routine = (isset($_GET["function"]) ? "FUNCTION" : "PROCEDURE");
|
||||||
|
|
||||||
$dropped = false;
|
$dropped = false;
|
||||||
if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"] && !$_POST["up"] && !$_POST["down"]) {
|
if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"] && !$_POST["up"] && !$_POST["down"]) {
|
||||||
if (strlen($PROCEDURE)) {
|
|
||||||
$dropped = query_redirect("DROP $routine " . idf_escape($PROCEDURE), substr(ME, 0, -1), lang('Routine has been dropped.'), $_POST["drop"], !$_POST["dropped"]);
|
|
||||||
}
|
|
||||||
if (!$_POST["drop"]) {
|
|
||||||
$set = array();
|
$set = array();
|
||||||
$fields = (array) $_POST["fields"];
|
$fields = (array) $_POST["fields"];
|
||||||
ksort($fields); // enforce fields order
|
ksort($fields); // enforce fields order
|
||||||
|
@ -16,12 +12,15 @@ if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"] && !$_POST["up"]
|
||||||
$set[] = (in_array($field["inout"], $inout) ? "$field[inout] " : "") . idf_escape($field["field"]) . process_type($field, "CHARACTER SET");
|
$set[] = (in_array($field["inout"], $inout) ? "$field[inout] " : "") . idf_escape($field["field"]) . process_type($field, "CHARACTER SET");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
query_redirect("CREATE $routine " . idf_escape($_POST["name"])
|
$dropped = drop_create(
|
||||||
. " (" . implode(", ", $set) . ")"
|
"DROP $routine " . idf_escape($PROCEDURE),
|
||||||
. (isset($_GET["function"]) ? " RETURNS" . process_type($_POST["returns"], "CHARACTER SET") : "")
|
"CREATE $routine " . idf_escape($_POST["name"]) . " (" . implode(", ", $set) . ")" . (isset($_GET["function"]) ? " RETURNS" . process_type($_POST["returns"], "CHARACTER SET") : "") . "\n$_POST[definition]",
|
||||||
. "\n$_POST[definition]"
|
substr(ME, 0, -1),
|
||||||
, substr(ME, 0, -1), (strlen($PROCEDURE) ? lang('Routine has been altered.') : lang('Routine has been created.')));
|
lang('Routine has been dropped.'),
|
||||||
}
|
lang('Routine has been altered.'),
|
||||||
|
lang('Routine has been created.'),
|
||||||
|
$PROCEDURE
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
page_header((strlen($PROCEDURE) ? (isset($_GET["function"]) ? lang('Alter function') : lang('Alter procedure')) . ": " . h($PROCEDURE) : (isset($_GET["function"]) ? lang('Create function') : lang('Create procedure'))), $error);
|
page_header((strlen($PROCEDURE) ? (isset($_GET["function"]) ? lang('Alter function') : lang('Alter procedure')) . ": " . h($PROCEDURE) : (isset($_GET["function"]) ? lang('Create function') : lang('Create procedure'))), $error);
|
||||||
|
@ -42,7 +41,7 @@ if ($_POST) {
|
||||||
<form action="" method="post" id="form">
|
<form action="" method="post" id="form">
|
||||||
<table cellspacing="0">
|
<table cellspacing="0">
|
||||||
<?php edit_fields($row["fields"], $collations, $routine); ?>
|
<?php edit_fields($row["fields"], $collations, $routine); ?>
|
||||||
<?php if (isset($_GET["function"])) { ?><tr><td><?php echo lang('Return type') . edit_type("returns", $row["returns"], $collations); ?><?php } ?>
|
<?php if (isset($_GET["function"])) { ?><tr><td><?php echo lang('Return type'); edit_type("returns", $row["returns"], $collations); ?><?php } ?>
|
||||||
</table>
|
</table>
|
||||||
<p><textarea name="definition" rows="10" cols="80" style="width: 98%;"><?php echo h($row["definition"]); ?></textarea>
|
<p><textarea name="definition" rows="10" cols="80" style="width: 98%;"><?php echo h($row["definition"]); ?></textarea>
|
||||||
<p>
|
<p>
|
||||||
|
|
|
@ -4,15 +4,16 @@ $trigger_time = array("BEFORE", "AFTER");
|
||||||
$trigger_event = array("INSERT", "UPDATE", "DELETE");
|
$trigger_event = array("INSERT", "UPDATE", "DELETE");
|
||||||
|
|
||||||
$dropped = false;
|
$dropped = false;
|
||||||
if ($_POST && !$error) {
|
if ($_POST && !$error && in_array($_POST["Timing"], $trigger_time) && in_array($_POST["Event"], $trigger_event)) {
|
||||||
if (strlen($_GET["name"])) {
|
$dropped = drop_create(
|
||||||
$dropped = query_redirect("DROP TRIGGER " . idf_escape($_GET["name"]), ME . "table=" . urlencode($TABLE), lang('Trigger has been dropped.'), $_POST["drop"], !$_POST["dropped"]);
|
"DROP TRIGGER " . idf_escape($_GET["name"]),
|
||||||
}
|
"CREATE TRIGGER " . idf_escape($_POST["Trigger"]) . " $_POST[Timing] $_POST[Event] ON " . idf_escape($TABLE) . " FOR EACH ROW\n$_POST[Statement]",
|
||||||
if (!$_POST["drop"]) {
|
ME . "table=" . urlencode($TABLE),
|
||||||
if (in_array($_POST["Timing"], $trigger_time) && in_array($_POST["Event"], $trigger_event)) {
|
lang('Trigger has been dropped.'),
|
||||||
query_redirect("CREATE TRIGGER " . idf_escape($_POST["Trigger"]) . " $_POST[Timing] $_POST[Event] ON " . idf_escape($TABLE) . " FOR EACH ROW\n$_POST[Statement]", ME . "table=" . urlencode($TABLE), (strlen($_GET["name"]) ? lang('Trigger has been altered.') : lang('Trigger has been created.')));
|
lang('Trigger has been altered.'),
|
||||||
}
|
lang('Trigger has been created.'),
|
||||||
}
|
$_GET["name"]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
page_header((strlen($_GET["name"]) ? lang('Alter trigger') . ": " . h($_GET["name"]) : lang('Create trigger')), $error, array("table" => $TABLE));
|
page_header((strlen($_GET["name"]) ? lang('Alter trigger') . ": " . h($_GET["name"]) : lang('Create trigger')), $error, array("table" => $TABLE));
|
||||||
|
|
|
@ -2,10 +2,15 @@
|
||||||
$TABLE = $_GET["view"];
|
$TABLE = $_GET["view"];
|
||||||
$dropped = false;
|
$dropped = false;
|
||||||
if ($_POST && !$error) {
|
if ($_POST && !$error) {
|
||||||
if (strlen($TABLE)) {
|
$dropped = drop_create(
|
||||||
$dropped = query_redirect("DROP VIEW " . idf_escape($TABLE), substr(ME, 0, -1), lang('View has been dropped.'), false, !$_POST["dropped"]);
|
"DROP VIEW " . idf_escape($TABLE),
|
||||||
}
|
"CREATE VIEW " . idf_escape($_POST["name"]) . " AS\n$_POST[select]",
|
||||||
query_redirect("CREATE VIEW " . idf_escape($_POST["name"]) . " AS\n$_POST[select]", ME . "table=" . urlencode($_POST["name"]), (strlen($TABLE) ? lang('View has been altered.') : lang('View has been created.')));
|
substr(ME, 0, -1),
|
||||||
|
lang('View has been dropped.'),
|
||||||
|
lang('View has been altered.'),
|
||||||
|
lang('View has been created.'),
|
||||||
|
$TABLE
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
page_header((strlen($TABLE) ? lang('Alter view') : lang('Create view')), $error, array("table" => $TABLE), $TABLE);
|
page_header((strlen($TABLE) ? lang('Alter view') : lang('Create view')), $error, array("table" => $TABLE), $TABLE);
|
||||||
|
|
Loading…
Reference in a new issue