query("SHOW COLUMNS FROM " . idf_escape($_GET["table"])); if (!$result) { $error = htmlspecialchars($dbh->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"]) . "" . htmlspecialchars($row["Type"]) . ($row["Null"] == "YES" ? " NULL" : "") . "\n"; } echo "
\n"; $result->free(); echo "

"; echo '' . lang('Alter table') . ''; echo ($auto_increment_only ? '' : ' ' . lang('Default values') . ''); echo ' ' . lang('Select table') . ''; echo ' ' . lang('New item') . ''; echo "

" . lang('Indexes') . "

\n"; $indexes = indexes($_GET["table"]); if ($indexes) { echo "\n"; foreach ($indexes as $index) { ksort($index["columns"]); // enforce correct columns order $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) { $link = (strlen($foreign_key["db"]) ? "" . htmlspecialchars($foreign_key["db"]) . "." : "") . htmlspecialchars($foreign_key["table"]); echo ""; echo "
" . implode(", ", array_map('htmlspecialchars', $foreign_key["source"])) . ""; echo '$link"; echo "(" . implode(", ", array_map('htmlspecialchars', $foreign_key["target"])) . ")"; echo "" . (!strlen($foreign_key["db"]) ? '' . lang('Alter') . '' : ' '); } echo "
\n"; } echo '

' . lang('Add foreign key') . "\n"; } } if ($dbh->server_info >= 5) { echo "

" . lang('Triggers') . "

\n"; $result = $dbh->query("SHOW TRIGGERS LIKE " . $dbh->quote(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"; }