Don't create in case of unsuccessful drop
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@183 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
parent
bac7a56172
commit
c9c2a9eb1e
|
@ -5,22 +5,24 @@ if ($_POST && !$error && !$_POST["add"] && !$_POST["change"] && !$_POST["change-
|
||||||
redirect($SELF . "table=" . urlencode($_GET["foreign"]), lang('Foreign key has been dropped.'));
|
redirect($SELF . "table=" . urlencode($_GET["foreign"]), lang('Foreign key has been dropped.'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$source = array_filter($_POST["source"], 'strlen');
|
if (!$_POST["drop"]) {
|
||||||
ksort($source);
|
$source = array_filter($_POST["source"], 'strlen');
|
||||||
$target = array();
|
ksort($source);
|
||||||
foreach ($source as $key => $val) {
|
$target = array();
|
||||||
$target[$key] = $_POST["target"][$key];
|
foreach ($source as $key => $val) {
|
||||||
}
|
$target[$key] = $_POST["target"][$key];
|
||||||
if ($mysql->query("
|
}
|
||||||
ALTER TABLE " . idf_escape($_GET["foreign"]) . " ADD FOREIGN KEY
|
if ($mysql->query("
|
||||||
" . (strlen($_GET["name"]) ? idf_escape($_GET["name"]) : "") . "
|
ALTER TABLE " . idf_escape($_GET["foreign"]) . " ADD FOREIGN KEY
|
||||||
(" . implode(", ", array_map('idf_escape', $source)) . ")
|
" . (strlen($_GET["name"]) ? idf_escape($_GET["name"]) : "") . "
|
||||||
REFERENCES " . idf_escape($_POST["table"]) . "
|
(" . implode(", ", array_map('idf_escape', $source)) . ")
|
||||||
(" . implode(", ", array_map('idf_escape', $target)) . ")
|
REFERENCES " . idf_escape($_POST["table"]) . "
|
||||||
" . (in_array($_POST["on_delete"], $on_actions) ? "ON DELETE $_POST[on_delete]" : "") . "
|
(" . implode(", ", array_map('idf_escape', $target)) . ")
|
||||||
" . (in_array($_POST["on_update"], $on_actions) ? "ON UPDATE $_POST[on_update]" : "") . "
|
" . (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.')));
|
")) {
|
||||||
|
redirect($SELF . "table=" . urlencode($_GET["foreign"]), (strlen($_GET["name"]) ? lang('Foreign key has been altered.') : lang('Foreign key has been created.')));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$error = $mysql->error;
|
$error = $mysql->error;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue