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
|
|
|
|
2010-05-27 11:31:08 +00:00
|
|
|
page_header(($fields && is_view($table_status) ? lang('View') : lang('Table')) . ": " . h($TABLE), $error);
|
2009-11-24 09:44:28 +00:00
|
|
|
$adminer->selectLinks($table_status);
|
2010-09-08 08:43:08 +00:00
|
|
|
$comment = $table_status["Comment"];
|
|
|
|
if ($comment != "") {
|
|
|
|
echo "<p>" . lang('Comment') . ": " . h($comment) . "\n";
|
|
|
|
}
|
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";
|
2010-04-21 12:01:32 +00:00
|
|
|
echo "<thead><tr><th>" . lang('Column') . "<td>" . lang('Type') . (support("comment") ? "<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>" : "");
|
2010-04-21 12:01:32 +00:00
|
|
|
echo (support("comment") ? "<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
|
|
|
|
2010-05-27 14:10:37 +00:00
|
|
|
if (!is_view($table_status)) {
|
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
|
|
|
|
2010-04-21 12:01:32 +00:00
|
|
|
if (fk_support($table_status)) {
|
2009-07-24 06:05:21 +00:00
|
|
|
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";
|
2010-05-07 13:44:22 +00:00
|
|
|
echo "<thead><tr><th>" . lang('Source') . "<td>" . lang('Target') . "<td>" . lang('ON DELETE') . "<td>" . lang('ON UPDATE') . ($jush != "sqlite" ? "<td> " : "") . "</thead>\n";
|
2009-07-24 06:05:21 +00:00
|
|
|
foreach ($foreign_keys as $name => $foreign_key) {
|
2010-05-20 21:05:25 +00:00
|
|
|
$link = ($foreign_key["db"] != "" ? "<b>" . h($foreign_key["db"]) . "</b>." : "") . 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>";
|
2010-05-20 21:05:25 +00:00
|
|
|
echo "(<i>" . implode("</i>, <i>", array_map('h', $foreign_key["target"])) . "</i>)";
|
2010-04-26 16:23:33 +00:00
|
|
|
echo "<td>$foreign_key[on_delete]\n";
|
|
|
|
echo "<td>$foreign_key[on_update]\n";
|
2010-05-07 13:44:22 +00:00
|
|
|
if ($jush != "sqlite") {
|
2010-04-22 23:05:16 +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";
|
|
|
|
}
|
2010-05-07 13:44:22 +00:00
|
|
|
if ($jush != "sqlite") {
|
2010-04-21 12:01:32 +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
|
|
|
}
|
|
|
|
|
2010-04-21 12:01:32 +00:00
|
|
|
if (support("trigger")) {
|
2009-07-24 06:05:21 +00:00
|
|
|
echo "<h3>" . lang('Triggers') . "</h3>\n";
|
2010-04-21 12:01:32 +00:00
|
|
|
$triggers = triggers($TABLE);
|
|
|
|
if ($triggers) {
|
2009-07-24 06:05:21 +00:00
|
|
|
echo "<table cellspacing='0'>\n";
|
2010-04-21 12:01:32 +00:00
|
|
|
foreach ($triggers as $key => $val) {
|
|
|
|
echo "<tr valign='top'><td>$val[0]<td>$val[1]<th>" . h($key) . "<td><a href='" . h(ME . 'trigger=' . urlencode($TABLE) . '&name=' . urlencode($key)) . "'>" . 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
|
|
|
}
|
|
|
|
}
|