$field) { //! detect changes if (strlen($field["field"]) && isset($types[$field["type"]])) { $fields[] = (!strlen($_GET["create"]) ? "" : (strlen($field["orig"]) ? "CHANGE " . idf_escape($field["orig"]) . " " : "ADD ")) . idf_escape($field["field"]) . " $field[type]" . ($field["length"] ? "(" . (preg_match("~^\\s*(?:$enum_length)(?:\\s*,\\s*(?:$enum_length))*\\s*\$~", $field["length"]) && preg_match_all("~$enum_length~", $field["length"], $matches) ? implode(",", $matches[0]) : intval($field["length"])) . ")" : "") . (preg_match('~int|float|double|decimal~', $field["type"]) && in_array($field["unsigned"], $unsigned) ? " $field[unsigned]" : "") . (preg_match('~char|text|enum|set~', $field["type"]) && $field["collation"] ? " COLLATE '" . $mysql->escape_string($field["collation"]) . "'" : "") . ($field["null"] ? "" : " NOT NULL") . ($key == $_POST["auto_increment"] ? " AUTO_INCREMENT$auto_increment_index" : "") . " COMMENT '" . $mysql->escape_string($field["comment"]) . "'" . (strlen($_GET["create"]) && !strlen($field["orig"]) ? $after : "") ; $after = "AFTER " . idf_escape($field["field"]); } elseif (strlen($field["orig"])) { $fields[] = "DROP " . idf_escape($field["orig"]); } } $status = ($_POST["Engine"] ? " ENGINE='" . $mysql->escape_string($_POST["Engine"]) . "'" : "") . ($_POST["Collation"] ? " COLLATE '" . $mysql->escape_string($_POST["Collation"]) . "'" : "") . " COMMENT='" . $mysql->escape_string($_POST["Comment"]) . "'" ; if (strlen($_GET["create"])) { $query = "ALTER TABLE " . idf_escape($_GET["create"]) . " " . implode(", ", $fields) . ", RENAME TO " . idf_escape($_POST["name"]) . ", $status"; $message = lang('Table has been altered.'); } else { $query = "CREATE TABLE " . idf_escape($_POST["name"]) . " (" . implode(", ", $fields) . ")$status"; $message = lang('Table has been created.'); } } if ($mysql->query($query)) { redirect(($_POST["drop"] ? substr($SELF, 0, -1) : $SELF . "table=" . urlencode($_POST["name"])), $message); } $error = $mysql->error; } page_header(strlen($_GET["create"]) ? lang('Alter table') . ': ' . htmlspecialchars($_GET["create"]) : lang('Create table')); if ($_POST) { $row = $_POST; ksort($row["fields"]); if (!$_POST["add"]) { echo "

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

\n"; $row["fields"] = array_values($row["fields"]); } else { array_splice($row["fields"], key($_POST["add"]), 0, array(array())); } if ($row["auto_increment"]) { $row["fields"][$row["auto_increment"] - 1]["auto_increment"] = true; } } elseif (strlen($_GET["create"])) { $row = table_status($_GET["create"]); if ($row["Engine"] == "InnoDB") { $row["Comment"] = preg_replace('~(?:(.+); )?InnoDB free: .*~', '\\1', $row["Comment"]); } $row["name"] = $_GET["create"]; $row["fields"] = array_values(fields($_GET["create"])); } else { $row = array("fields" => array(array())); } $collations = collations(); ?>

: " />

$field) { $i++; ?>
" />" maxlength="64" /> " size="3" /> checked="checked" /> checked="checked" /> " maxlength="255" />

: " maxlength="60" />