mirror of
https://github.com/vrana/adminer.git
synced 2025-08-24 07:02:51 +02:00
Substitute table name to $TABLE
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@1047 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
<?php
|
||||
$TABLE = $_GET["foreign"];
|
||||
if ($_POST && !$error && !$_POST["add"] && !$_POST["change"] && !$_POST["change-js"]) {
|
||||
if ($_POST["drop"]) {
|
||||
query_redirect("ALTER TABLE " . idf_escape($_GET["foreign"]) . "\nDROP FOREIGN KEY " . idf_escape($_GET["name"]), ME . "table=" . urlencode($_GET["foreign"]), lang('Foreign key has been dropped.'));
|
||||
query_redirect("ALTER TABLE " . idf_escape($TABLE) . "\nDROP FOREIGN KEY " . idf_escape($_GET["name"]), ME . "table=" . urlencode($TABLE), lang('Foreign key has been dropped.'));
|
||||
} else {
|
||||
$source = array_filter($_POST["source"], 'strlen');
|
||||
ksort($source); // enforce input order
|
||||
@@ -9,19 +10,19 @@ if ($_POST && !$error && !$_POST["add"] && !$_POST["change"] && !$_POST["change-
|
||||
foreach ($source as $key => $val) {
|
||||
$target[$key] = $_POST["target"][$key];
|
||||
}
|
||||
query_redirect("ALTER TABLE " . idf_escape($_GET["foreign"])
|
||||
query_redirect("ALTER TABLE " . idf_escape($TABLE)
|
||||
. (strlen($_GET["name"]) ? "\nDROP FOREIGN KEY " . idf_escape($_GET["name"]) . "," : "")
|
||||
. "\nADD 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]" : "")
|
||||
, ME . "table=" . urlencode($_GET["foreign"]), (strlen($_GET["name"]) ? lang('Foreign key has been altered.') : lang('Foreign key has been created.')));
|
||||
, ME . "table=" . urlencode($TABLE), (strlen($_GET["name"]) ? lang('Foreign key has been altered.') : lang('Foreign key has been created.')));
|
||||
$error = lang('Source and target columns must have the same data type, there must be an index on the target columns and referenced data must exist.') . "<br>$error"; //! no partitioning
|
||||
}
|
||||
}
|
||||
|
||||
page_header(lang('Foreign key'), $error, array("table" => $_GET["foreign"]), $_GET["foreign"]);
|
||||
page_header(lang('Foreign key'), $error, array("table" => $TABLE), $TABLE);
|
||||
|
||||
$row = array("table" => $_GET["foreign"], "source" => array(""));
|
||||
$row = array("table" => $TABLE, "source" => array(""));
|
||||
if ($_POST) {
|
||||
$row = $_POST;
|
||||
ksort($row["source"]);
|
||||
@@ -31,13 +32,13 @@ if ($_POST) {
|
||||
$row["target"] = array();
|
||||
}
|
||||
} elseif (strlen($_GET["name"])) {
|
||||
$foreign_keys = foreign_keys($_GET["foreign"]);
|
||||
$foreign_keys = foreign_keys($TABLE);
|
||||
$row = $foreign_keys[$_GET["name"]];
|
||||
$row["source"][] = "";
|
||||
}
|
||||
|
||||
$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"])));
|
||||
$source = get_vals("SHOW COLUMNS FROM " . idf_escape($TABLE)); //! no text and blob
|
||||
$target = ($TABLE === $row["table"] ? $source : get_vals("SHOW COLUMNS FROM " . idf_escape($row["table"])));
|
||||
?>
|
||||
|
||||
<form action="" method="post">
|
||||
|
Reference in New Issue
Block a user