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.')); } } $source = array_filter($_POST["source"], 'strlen'); ksort($source); $target = array(); foreach ($source as $key => $val) { $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]" : "") . " ")) { redirect($SELF . "table=" . urlencode($_GET["foreign"]), (strlen($_GET["name"]) ? lang('Foreign key has been altered.') : lang('Foreign key has been created.'))); } $error = $mysql->error; } page_header(lang('Foreign key') . ": " . htmlspecialchars($_GET["foreign"])); $tables = array(); $result = $mysql->query("SHOW TABLE STATUS"); while ($row = $result->fetch_assoc()) { if ($row["Engine"] == "InnoDB") { $tables[] = $row["Name"]; } } $result->free(); if ($_POST) { $row = $_POST; ksort($row["source"]); if ($_POST["add"]) { $row["source"][] = ""; } elseif ($_POST["change"] || $_POST["change-js"]) { $row["target"] = array(); } else { echo "

" . lang('Unable to operate foreign keys') . ": " . htmlspecialchars($error) . "

\n"; } } elseif (strlen($_GET["name"])) { $foreign_keys = foreign_keys($_GET["foreign"]); $row = $foreign_keys[$_GET["name"]]; } else { $row = array("table" => $_GET["foreign"], "source" => array("")); } $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"]))); ?>

:

$val) { echo ""; echo ""; echo ""; echo "\n"; } ?>