MS SQL: Foreign key in create table

This commit is contained in:
Jakub Vrana 2010-11-28 16:28:15 +01:00
parent ca27ffc2c4
commit 4a2fe5eac1
3 changed files with 5 additions and 1 deletions

View file

@ -44,7 +44,7 @@ if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"] && !$_POST["up"]
$fields[] = array($field["orig"], $process_field, $after);
}
if (isset($foreign_key)) {
$foreign[] = ($TABLE != "" ? "ADD" : " ") . " FOREIGN KEY (" . idf_escape($field["field"]) . ") REFERENCES " . idf_escape($foreign_keys[$field["type"]]) . " (" . idf_escape($type_field["field"]) . ")" . (in_array($field["on_delete"], $on_actions) ? " ON DELETE $field[on_delete]" : "");
$foreign[] = ($TABLE != "" ? "ADD" : " ") . " FOREIGN KEY (" . idf_escape($field["field"]) . ") REFERENCES " . table($foreign_keys[$field["type"]]) . " (" . idf_escape($type_field["field"]) . ")" . (in_array($field["on_delete"], $on_actions) ? " ON DELETE $field[on_delete]" : "");
}
$after = "AFTER " . idf_escape($field["field"]);
} elseif ($field["orig"] != "") {

View file

@ -425,6 +425,9 @@ WHERE OBJECT_NAME(i.object_id) = " . q($table)
if ($table != $name) {
queries("EXEC sp_rename " . q(table($table)) . ", " . q($name));
}
if ($foreign) {
$alter[""] = $foreign;
}
foreach ($alter as $key => $val) {
if (!queries("ALTER TABLE " . idf_escape($name) . " $key" . implode(",", $val))) {
return false;

View file

@ -42,6 +42,7 @@ Column rights - http://www.postgresql.org/docs/8.4/static/functions-info.html
bool in Editor
MS SQL:
Edit of AI column
Non UTF-8 character sets
Detection of table collation
PDO_MSSQL and PDO_SQLSRV driver with seek