diff --git a/foreign.inc.php b/foreign.inc.php index 77a0d633..7c1aeec3 100644 --- a/foreign.inc.php +++ b/foreign.inc.php @@ -13,6 +13,7 @@ if ($_POST && !$error && !$_POST["add"] && !$_POST["change"] && !$_POST["change- } 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)) . ") @@ -26,6 +27,17 @@ if ($_POST && !$error && !$_POST["add"] && !$_POST["change"] && !$_POST["change- 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(); +$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"]))); + if ($_POST) { $row = $_POST; ksort($row["source"]); @@ -46,15 +58,13 @@ if ($_POST) {