2007-07-02 05:51:26 +00:00
|
|
|
<?php
|
2009-08-29 13:57:50 +00:00
|
|
|
$TABLE = $_GET["table"];
|
2009-10-16 12:26:16 +00:00
|
|
|
$fields = fields($TABLE);
|
|
|
|
if (!$fields) {
|
2009-12-17 15:31:24 +00:00
|
|
|
$error = error();
|
2008-04-10 14:37:10 +00:00
|
|
|
}
|
2009-10-16 12:26:16 +00:00
|
|
|
$table_status = ($fields ? table_status($TABLE) : array());
|
2009-07-20 12:12:55 +00:00
|
|
|
|
2009-11-24 09:44:28 +00:00
|
|
|
page_header(($fields && !isset($table_status["Rows"]) ? lang('View') : lang('Table')) . ": " . h($TABLE), $error);
|
|
|
|
$adminer->selectLinks($table_status);
|
2008-04-10 14:37:10 +00:00
|
|
|
|
2009-10-16 12:26:16 +00:00
|
|
|
if ($fields) {
|
2009-08-20 14:04:24 +00:00
|
|
|
echo "<table cellspacing='0'>\n";
|
|
|
|
echo "<thead><tr><th>" . lang('Column') . "<td>" . lang('Type') . "<td>" . lang('Comment') . "</thead>\n";
|
2009-10-16 12:26:16 +00:00
|
|
|
foreach ($fields as $field) {
|
2009-10-28 12:14:38 +00:00
|
|
|
echo "<tr" . odd() . "><th>" . h($field["field"]);
|
2009-10-16 12:26:16 +00:00
|
|
|
echo "<td>" . h($field["full_type"]) . ($field["null"] ? " <i>NULL</i>" : "") . ($field["auto_increment"] ? " <i>" . lang('Auto Increment') . "</i>" : "");
|
|
|
|
echo "<td>" . nbsp($field["comment"]);
|
2009-08-19 12:07:37 +00:00
|
|
|
echo "\n";
|
2007-07-02 05:51:26 +00:00
|
|
|
}
|
|
|
|
echo "</table>\n";
|
2007-07-09 06:12:22 +00:00
|
|
|
|
2009-09-20 07:31:46 +00:00
|
|
|
if (isset($table_status["Rows"])) {
|
2009-07-24 06:05:21 +00:00
|
|
|
echo "<h3>" . lang('Indexes') . "</h3>\n";
|
2009-08-29 13:57:50 +00:00
|
|
|
$indexes = indexes($TABLE);
|
2009-07-24 06:05:21 +00:00
|
|
|
if ($indexes) {
|
2009-05-01 10:41:33 +00:00
|
|
|
echo "<table cellspacing='0'>\n";
|
2010-02-12 21:30:36 +00:00
|
|
|
foreach ($indexes as $name => $index) {
|
2009-07-24 06:05:21 +00:00
|
|
|
ksort($index["columns"]); // enforce correct columns order
|
|
|
|
$print = array();
|
|
|
|
foreach ($index["columns"] as $key => $val) {
|
2009-07-28 16:20:50 +00:00
|
|
|
$print[] = "<i>" . h($val) . "</i>" . ($index["lengths"][$key] ? "(" . $index["lengths"][$key] . ")" : "");
|
2009-07-24 06:05:21 +00:00
|
|
|
}
|
2010-02-12 21:30:36 +00:00
|
|
|
echo "<tr title='" . h($name) . "'><th>$index[type]<td>" . implode(", ", $print) . "\n";
|
2007-07-13 07:15:45 +00:00
|
|
|
}
|
|
|
|
echo "</table>\n";
|
2007-07-06 13:03:13 +00:00
|
|
|
}
|
2009-08-29 13:57:50 +00:00
|
|
|
echo '<p><a href="' . h(ME) . 'indexes=' . urlencode($TABLE) . '">' . lang('Alter indexes') . "</a>\n";
|
2009-07-24 06:05:21 +00:00
|
|
|
|
|
|
|
if ($table_status["Engine"] == "InnoDB") {
|
|
|
|
echo "<h3>" . lang('Foreign keys') . "</h3>\n";
|
2009-08-29 13:57:50 +00:00
|
|
|
$foreign_keys = foreign_keys($TABLE);
|
2009-07-24 06:05:21 +00:00
|
|
|
if ($foreign_keys) {
|
|
|
|
echo "<table cellspacing='0'>\n";
|
|
|
|
foreach ($foreign_keys as $name => $foreign_key) {
|
2010-01-09 23:33:41 +00:00
|
|
|
$link = ($foreign_key["db"] != "" ? "<strong>" . h($foreign_key["db"]) . "</strong>." : "") . h($foreign_key["table"]);
|
2009-07-24 06:05:21 +00:00
|
|
|
echo "<tr>";
|
2009-07-28 16:20:50 +00:00
|
|
|
echo "<th><i>" . implode("</i>, <i>", array_map('h', $foreign_key["source"])) . "</i>";
|
2010-01-09 23:33:41 +00:00
|
|
|
echo "<td><a href='" . h($foreign_key["db"] != "" ? preg_replace('~db=[^&]*~', "db=" . urlencode($foreign_key["db"]), ME) : ME) . "table=" . urlencode($foreign_key["table"]) . "'>$link</a>";
|
2009-07-28 16:20:50 +00:00
|
|
|
echo "(<em>" . implode("</em>, <em>", array_map('h', $foreign_key["target"])) . "</em>)";
|
2009-11-19 20:04:55 +00:00
|
|
|
echo '<td><a href="' . h(ME . 'foreign=' . urlencode($TABLE) . '&name=' . urlencode($name)) . '">' . lang('Alter') . '</a>';
|
2009-07-24 06:05:21 +00:00
|
|
|
}
|
|
|
|
echo "</table>\n";
|
|
|
|
}
|
2009-08-29 13:57:50 +00:00
|
|
|
echo '<p><a href="' . h(ME) . 'foreign=' . urlencode($TABLE) . '">' . lang('Add foreign key') . "</a>\n";
|
2009-07-24 06:05:21 +00:00
|
|
|
}
|
|
|
|
|
2009-09-22 10:51:40 +00:00
|
|
|
if ($connection->server_info >= 5) {
|
2009-07-24 06:05:21 +00:00
|
|
|
echo "<h3>" . lang('Triggers') . "</h3>\n";
|
2009-09-22 10:51:40 +00:00
|
|
|
$result = $connection->query("SHOW TRIGGERS LIKE " . $connection->quote(addcslashes($TABLE, "%_")));
|
2009-07-24 06:05:21 +00:00
|
|
|
if ($result->num_rows) {
|
|
|
|
echo "<table cellspacing='0'>\n";
|
|
|
|
while ($row = $result->fetch_assoc()) {
|
2009-08-29 13:57:50 +00:00
|
|
|
echo "<tr valign='top'><td>$row[Timing]<td>$row[Event]<th>" . h($row["Trigger"]) . "<td><a href='" . h(ME . 'trigger=' . urlencode($TABLE) . '&name=' . urlencode($row["Trigger"])) . "'>" . lang('Alter') . "</a>\n";
|
2009-07-24 06:05:21 +00:00
|
|
|
}
|
|
|
|
echo "</table>\n";
|
|
|
|
}
|
2009-08-29 13:57:50 +00:00
|
|
|
echo '<p><a href="' . h(ME) . 'trigger=' . urlencode($TABLE) . '">' . lang('Add trigger') . "</a>\n";
|
2007-07-06 09:55:51 +00:00
|
|
|
}
|
2007-07-02 05:51:26 +00:00
|
|
|
}
|
|
|
|
}
|