2007-07-02 05:51:26 +00:00
|
|
|
<?php
|
|
|
|
page_header(lang('Table') . ": " . htmlspecialchars($_GET["table"]));
|
|
|
|
|
2007-07-10 13:30:42 +00:00
|
|
|
$result = $mysql->query("SHOW COLUMNS FROM " . idf_escape($_GET["table"]));
|
2007-07-06 13:03:13 +00:00
|
|
|
if (!$result) {
|
2007-07-10 13:30:42 +00:00
|
|
|
echo "<p class='error'>" . lang('Unable to show the table definition') . ": " . $mysql->error . ".</p>\n";
|
2007-07-06 13:03:13 +00:00
|
|
|
} else {
|
2007-07-09 06:12:22 +00:00
|
|
|
$auto_increment_only = true;
|
2007-07-02 05:51:26 +00:00
|
|
|
echo "<table border='1' cellspacing='0' cellpadding='2'>\n";
|
2007-07-10 13:30:42 +00:00
|
|
|
while ($row = $result->fetch_assoc()) {
|
2007-07-09 06:12:22 +00:00
|
|
|
if (!$row["auto_increment"]) {
|
|
|
|
$auto_increment_only = false;
|
|
|
|
}
|
2007-07-06 15:48:57 +00:00
|
|
|
echo "<tr><th>" . htmlspecialchars($row["Field"]) . "</th><td>$row[Type]" . ($row["Null"] == "YES" ? " <i>NULL</i>" : "") . "</td></tr>\n";
|
2007-07-02 05:51:26 +00:00
|
|
|
}
|
|
|
|
echo "</table>\n";
|
2007-07-10 13:30:42 +00:00
|
|
|
$result->free();
|
2007-07-09 06:12:22 +00:00
|
|
|
|
|
|
|
echo "<p>";
|
|
|
|
echo '<a href="' . htmlspecialchars($SELF) . 'create=' . urlencode($_GET["table"]) . '">' . lang('Alter table') . '</a>';
|
2007-07-09 14:48:46 +00:00
|
|
|
echo ($auto_increment_only ? '' : ' <a href="' . htmlspecialchars($SELF) . 'default=' . urlencode($_GET["table"]) . '">' . lang('Default values') . '</a>');
|
2007-07-09 06:12:22 +00:00
|
|
|
echo "</p>\n";
|
2007-07-06 13:03:13 +00:00
|
|
|
|
|
|
|
echo "<h3>" . lang('Indexes') . "</h3>\n";
|
|
|
|
$indexes = indexes($_GET["table"]);
|
|
|
|
if ($indexes) {
|
|
|
|
echo "<table border='1' cellspacing='0' cellpadding='2'>\n";
|
|
|
|
foreach ($indexes as $index) {
|
|
|
|
ksort($index["columns"]);
|
|
|
|
echo "<tr><td>$index[type]</td><td><i>" . implode("</i>, <i>", $index["columns"]) . "</i></td></tr>\n";
|
|
|
|
}
|
|
|
|
echo "</table>\n";
|
|
|
|
}
|
|
|
|
echo '<p><a href="' . htmlspecialchars($SELF) . 'indexes=' . urlencode($_GET["table"]) . '">' . lang('Alter indexes') . "</a></p>\n";
|
|
|
|
|
2007-07-11 16:02:57 +00:00
|
|
|
echo "<h3>" . lang('Foreign keys') . "</h3>\n";
|
2007-07-06 13:03:13 +00:00
|
|
|
$foreign_keys = foreign_keys($_GET["table"]);
|
|
|
|
if ($foreign_keys) {
|
|
|
|
echo "<table border='1' cellspacing='0' cellpadding='2'>\n";
|
2007-07-11 16:02:57 +00:00
|
|
|
foreach ($foreign_keys as $name => $foreign_key) {
|
|
|
|
echo "<tr>";
|
|
|
|
echo "<td><i>" . implode("</i>, <i>", $foreign_key[2]) . "</i></td>";
|
|
|
|
$link = (strlen($foreign_key[0]) && $foreign_key[0] !== $_GET["db"] ? "<strong>" . htmlspecialchars($foreign_key[0]) . "</strong>." : "") . htmlspecialchars($foreign_key[1]);
|
|
|
|
echo '<td><a href="' . htmlspecialchars(strlen($foreign_key[0]) ? preg_replace('~db=[^&]*~', "db=" . urlencode($foreign_key[0]), $SELF) : $SELF) . "table=" . urlencode($foreign_key[1]) . "\">$link</a>(<em>" . implode("</em>, <em>", $foreign_key[3]) . "</em>)</td>";
|
|
|
|
echo '<td><a href="' . htmlspecialchars($SELF) . 'foreign=' . urlencode($_GET["table"]) . '&name=' . urlencode($name) . '">' . lang('Alter') . "</a></td>";
|
|
|
|
echo "</tr>\n";
|
2007-07-06 13:03:13 +00:00
|
|
|
}
|
|
|
|
echo "</table>\n";
|
2007-07-02 10:24:49 +00:00
|
|
|
}
|
2007-07-11 16:02:57 +00:00
|
|
|
echo '<p><a href="' . htmlspecialchars($SELF) . 'foreign=' . urlencode($_GET["table"]) . '">' . lang('Add foreign key') . "</a></p>\n";
|
2007-07-02 10:24:49 +00:00
|
|
|
}
|
|
|
|
|
2007-07-10 13:30:42 +00:00
|
|
|
if ($mysql->server_info >= 5) {
|
2007-07-10 14:16:44 +00:00
|
|
|
$result = $mysql->query("SHOW TRIGGERS LIKE '" . $mysql->escape_string($_GET["table"]) . "'");
|
2007-07-10 13:30:42 +00:00
|
|
|
if ($result->num_rows) {
|
2007-07-06 09:55:51 +00:00
|
|
|
echo "<h3>" . lang('Triggers') . "</h3>\n";
|
2007-07-06 11:48:19 +00:00
|
|
|
echo "<table border='0' cellspacing='0' cellpadding='2'>\n";
|
2007-07-10 13:30:42 +00:00
|
|
|
while ($row = $result->fetch_assoc()) {
|
2007-07-10 06:30:04 +00:00
|
|
|
echo "<tr valign='top'><th>$row[Timing]</th><th>$row[Event]</th><td><pre class='jush-sql'>" . htmlspecialchars($row["Statement"]) . "</pre></td></tr>\n";
|
2007-07-06 09:55:51 +00:00
|
|
|
}
|
|
|
|
echo "</table>\n";
|
2007-07-02 05:51:26 +00:00
|
|
|
}
|
2007-07-10 13:30:42 +00:00
|
|
|
$result->free();
|
2007-07-02 05:51:26 +00:00
|
|
|
}
|