From 2a03e63d757b6476a8026e34f16637ad782a0fd9 Mon Sep 17 00:00:00 2001 From: jakubvrana Date: Sat, 4 Aug 2007 20:26:58 +0000 Subject: [PATCH] Drop and re-create at once JavaScript for next field git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@301 7c3ca157-0c34-0410-bff1-cbf682f78f5c --- foreign.inc.php | 44 ++++++++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/foreign.inc.php b/foreign.inc.php index 8094a2be..7fbfad86 100644 --- a/foreign.inc.php +++ b/foreign.inc.php @@ -1,9 +1,10 @@ query("ALTER TABLE " . idf_escape($_GET["foreign"]) . " DROP FOREIGN KEY " . idf_escape($_GET["name"])) && $_POST["drop"]) { - redirect($SELF . "table=" . urlencode($_GET["foreign"]), lang('Foreign key has been dropped.')); - } - if (!$_POST["drop"]) { + if ($_POST["drop"]) { + if ($mysql->query("ALTER TABLE " . idf_escape($_GET["foreign"]) . " DROP FOREIGN KEY " . idf_escape($_GET["name"]))) { + redirect($SELF . "table=" . urlencode($_GET["foreign"]), lang('Foreign key has been dropped.')); + } + } else { $source = array_filter($_POST["source"], 'strlen'); ksort($source); $target = array(); @@ -11,14 +12,13 @@ if ($_POST && !$error && !$_POST["add"] && !$_POST["change"] && !$_POST["change- $target[$key] = $_POST["target"][$key]; } if ($mysql->query(" - ALTER TABLE " . idf_escape($_GET["foreign"]) . " ADD FOREIGN KEY - " . (strlen($_GET["name"]) ? idf_escape($_GET["name"]) : "") . " - (" . implode(", ", array_map('idf_escape', $source)) . ") - REFERENCES " . idf_escape($_POST["table"]) . " - (" . implode(", ", array_map('idf_escape', $target)) . ") - " . (in_array($_POST["on_delete"], $on_actions) ? "ON DELETE $_POST[on_delete]" : "") . " - " . (in_array($_POST["on_update"], $on_actions) ? "ON UPDATE $_POST[on_update]" : "") . " - ")) { + ALTER TABLE " . idf_escape($_GET["foreign"]) + . (strlen($_GET["name"]) ? " DROP FOREIGN KEY " . idf_escape($_GET["name"]) . "," : "") . " + ADD FOREIGN KEY (" . implode(", ", array_map('idf_escape', $source)) . ") + REFERENCES " . idf_escape($_POST["table"]) . " (" . implode(", ", array_map('idf_escape', $target)) . ")" + . (in_array($_POST["on_delete"], $on_actions) ? " ON DELETE $_POST[on_delete]" : "") + . (in_array($_POST["on_update"], $on_actions) ? " ON UPDATE $_POST[on_update]" : "") + )) { redirect($SELF . "table=" . urlencode($_GET["foreign"]), (strlen($_GET["name"]) ? lang('Foreign key has been altered.') : lang('Foreign key has been created.'))); } } @@ -49,6 +49,7 @@ if ($_POST) { } elseif (strlen($_GET["name"])) { $foreign_keys = foreign_keys($_GET["foreign"]); $row = $foreign_keys[$_GET["name"]]; + $row["source"][] = ""; } else { $row = array("table" => $_GET["foreign"], "source" => array("")); } @@ -56,6 +57,19 @@ if ($_POST) { $source = get_vals("SHOW COLUMNS FROM " . idf_escape($_GET["foreign"])); //! no text and blob $target = ($_GET["foreign"] === $row["table"] ? $source : get_vals("SHOW COLUMNS FROM " . idf_escape($row["table"]))); ?> + + +

: @@ -66,11 +80,13 @@ $target = ($_GET["foreign"] === $row["table"] ? $source : get_vals("SHOW COLUMNS $val) { echo ""; - echo ""; + echo ""; echo ""; echo "\n"; + $j++; } ?>
@@ -81,7 +97,7 @@ foreach ($row["source"] as $key => $val) {

-

+
-- 2.39.5