query("SHOW COLUMNS FROM " . idf_escape($_GET["table"]));
if (!$result) {
$error = $mysql->error;
}
page_header(lang('Table') . ": " . htmlspecialchars($_GET["table"]), $error);
if ($result) {
$table_status = table_status($_GET["table"]);
$auto_increment_only = true;
echo "
\n";
while ($row = $result->fetch_assoc()) {
if (!$row["auto_increment"]) {
$auto_increment_only = false;
}
echo "" . htmlspecialchars($row["Field"]) . " | $row[Type]" . ($row["Null"] == "YES" ? " NULL" : "") . " |
\n";
}
echo "
\n";
$result->free();
echo "";
echo '' . lang('Alter table') . '';
echo ($auto_increment_only ? '' : ' ' . lang('Default values') . '');
echo "
\n";
echo "" . lang('Indexes') . "
\n";
$indexes = indexes($_GET["table"]);
if ($indexes) {
echo "\n";
foreach ($indexes as $index) {
ksort($index["columns"]);
$print = array();
foreach ($index["columns"] as $key => $val) {
$print[] = "" . htmlspecialchars($val) . "" . ($index["lengths"][$key] ? "(" . $index["lengths"][$key] . ")" : "");
}
echo "$index[type] | " . implode(", ", $print) . " |
\n";
}
echo "
\n";
}
echo '' . lang('Alter indexes') . "
\n";
if ($table_status["Engine"] == "InnoDB") {
echo "" . lang('Foreign keys') . "
\n";
$foreign_keys = foreign_keys($_GET["table"]);
if ($foreign_keys) {
echo "\n";
foreach ($foreign_keys as $name => $foreign_key) {
echo "";
echo "" . implode(", ", array_map('htmlspecialchars', $foreign_key["source"])) . " | ";
$link = (strlen($foreign_key["db"]) ? "" . htmlspecialchars($foreign_key["db"]) . "." : "") . htmlspecialchars($foreign_key["table"]);
echo '$link";
echo "(" . implode(", ", array_map('htmlspecialchars', $foreign_key["target"])) . ") | ";
echo '' . (!strlen($foreign_key["db"]) ? '' . lang('Alter') . '' : ' ') . ' | ';
echo "
\n";
}
echo "
\n";
}
echo '' . lang('Add foreign key') . "
\n";
}
}
if ($mysql->server_info >= 5) {
echo "" . lang('Triggers') . "
\n";
$result = $mysql->query("SHOW TRIGGERS LIKE '" . $mysql->escape_string(addcslashes($_GET["table"], "%_")) . "'");
if ($result->num_rows) {
echo "\n";
while ($row = $result->fetch_assoc()) {
echo "$row[Timing] | $row[Event] | " . htmlspecialchars($row["Trigger"]) . " | ' . lang('Alter') . " |
\n";
}
echo "
\n";
}
$result->free();
echo '' . lang('Add trigger') . "
\n";
}