$val) {
$target[$key] = $row["target"][$key];
}
$row["target"] = $target;
}
if ($jush == "sqlite") {
queries_redirect($location, $message, recreate_table($TABLE, $TABLE, array(), array(), array(" $name" => ($_POST["drop"] ? "" : " " . format_foreign_key($row)))));
} else {
$alter = "ALTER TABLE " . table($TABLE);
$drop = "\nDROP " . ($jush == "sql" ? "FOREIGN KEY " : "CONSTRAINT ") . idf_escape($name);
if ($_POST["drop"]) {
query_redirect($alter . $drop, $location, $message);
} else {
query_redirect($alter . ($name != "" ? "$drop," : "") . "\nADD" . format_foreign_key($row), $location, $message);
$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), h($TABLE));
if ($_POST) {
ksort($row["source"]);
if ($_POST["add"]) {
$row["source"][] = "";
} elseif ($_POST["change"] || $_POST["change-js"]) {
$row["target"] = array();
}
} elseif ($name != "") {
$foreign_keys = foreign_keys($TABLE);
$row = $foreign_keys[$name];
$row["source"][] = "";
} else {
$row["table"] = $TABLE;
$row["source"] = array("");
}
$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'));
?>