$val) { $target[$key] = $_POST["target"][$key]; } query_redirect("ALTER TABLE " . table($TABLE) . ($_GET["name"] != "" ? "\nDROP " . ($jush == "sql" ? "FOREIGN KEY " : "CONSTRAINT ") . idf_escape($_GET["name"]) . "," : "") . "\nADD FOREIGN KEY (" . implode(", ", array_map('idf_escape', $source)) . ") REFERENCES " . table($_POST["table"]) . " (" . implode(", ", array_map('idf_escape', $target)) . ")" //! reuse $_GET["name"] - check in older MySQL versions . (ereg("^($on_actions)\$", $_POST["on_delete"]) ? " ON DELETE $_POST[on_delete]" : "") . (ereg("^($on_actions)\$", $_POST["on_update"]) ? " ON UPDATE $_POST[on_update]" : "") , ME . "table=" . urlencode($TABLE), ($_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.') . "
$error"; //! no partitioning } } page_header(lang('Foreign key'), $error, array("table" => $TABLE), $TABLE); $row = array("table" => $TABLE, "source" => array("")); if ($_POST) { $row = $_POST; ksort($row["source"]); if ($_POST["add"]) { $row["source"][] = ""; } elseif ($_POST["change"] || $_POST["change-js"]) { $row["target"] = array(); } } elseif ($_GET["name"] != "") { $foreign_keys = foreign_keys($TABLE); $row = $foreign_keys[$_GET["name"]]; $row["source"][] = ""; } $source = array_keys(fields($TABLE)); //! no text and blob $target = ($TABLE === $row["table"] ? $source : array_keys(fields($row["table"]))); $referencable = array_keys(array_filter(table_status('', true), 'fk_support')); ?>

:

$val) { echo ""; echo "
" . html_select("source[" . (+$key) . "]", array(-1 => "") + $source, $val, ($j == count($row["source"]) - 1 ? "foreignAddRow(this);" : 1)); echo "" . html_select("target[" . (+$key) . "]", $target, $row["target"][$key]); $j++; } ?>

: "") + explode("|", $on_actions), $row["on_delete"]); ?> : "") + explode("|", $on_actions), $row["on_update"]); ?>

>