1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-16 11:34:10 +02:00

Display foreign keys only for InnoDB

git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@158 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
jakubvrana
2007-07-13 07:15:45 +00:00
parent 5003ad5075
commit 31e29a87c1
3 changed files with 19 additions and 16 deletions

View File

@@ -73,8 +73,7 @@ if ($_POST) {
$row["fields"][$row["auto_increment"] - 1]["auto_increment"] = true; $row["fields"][$row["auto_increment"] - 1]["auto_increment"] = true;
} }
} elseif (strlen($_GET["create"])) { } elseif (strlen($_GET["create"])) {
$result = table_status($_GET["create"]); $row = table_status($_GET["create"]);
$row = $result->fetch_assoc();
$row["name"] = $_GET["create"]; $row["name"] = $_GET["create"];
$row["fields"] = array_values(fields($_GET["create"])); $row["fields"] = array_values(fields($_GET["create"]));
} else { } else {

View File

@@ -42,7 +42,8 @@ function get_vals($query) {
function table_status($table) { function table_status($table) {
global $mysql; global $mysql;
return $mysql->query("SHOW TABLE STATUS LIKE '" . $mysql->escape_string(addcslashes($table, "%_")) . "'"); $result = $mysql->query("SHOW TABLE STATUS LIKE '" . $mysql->escape_string(addcslashes($table, "%_")) . "'");
return $result->fetch_assoc();
} }
function fields($table) { function fields($table) {

View File

@@ -5,6 +5,7 @@ $result = $mysql->query("SHOW COLUMNS FROM " . idf_escape($_GET["table"]));
if (!$result) { if (!$result) {
echo "<p class='error'>" . lang('Unable to show the table definition') . ": " . $mysql->error . ".</p>\n"; echo "<p class='error'>" . lang('Unable to show the table definition') . ": " . $mysql->error . ".</p>\n";
} else { } else {
$table_status = table_status($_GET["table"]);
$auto_increment_only = true; $auto_increment_only = true;
echo "<table border='1' cellspacing='0' cellpadding='2'>\n"; echo "<table border='1' cellspacing='0' cellpadding='2'>\n";
while ($row = $result->fetch_assoc()) { while ($row = $result->fetch_assoc()) {
@@ -33,21 +34,23 @@ if (!$result) {
} }
echo '<p><a href="' . htmlspecialchars($SELF) . 'indexes=' . urlencode($_GET["table"]) . '">' . lang('Alter indexes') . "</a></p>\n"; echo '<p><a href="' . htmlspecialchars($SELF) . 'indexes=' . urlencode($_GET["table"]) . '">' . lang('Alter indexes') . "</a></p>\n";
echo "<h3>" . lang('Foreign keys') . "</h3>\n"; if ($table_status["Engine"] == "InnoDB") {
$foreign_keys = foreign_keys($_GET["table"]); echo "<h3>" . lang('Foreign keys') . "</h3>\n";
if ($foreign_keys) { $foreign_keys = foreign_keys($_GET["table"]);
echo "<table border='1' cellspacing='0' cellpadding='2'>\n"; if ($foreign_keys) {
foreach ($foreign_keys as $name => $foreign_key) { echo "<table border='1' cellspacing='0' cellpadding='2'>\n";
echo "<tr>"; foreach ($foreign_keys as $name => $foreign_key) {
echo "<td><i>" . implode("</i>, <i>", $foreign_key["source"]) . "</i></td>"; echo "<tr>";
$link = (strlen($foreign_key["db"]) ? "<strong>" . htmlspecialchars($foreign_key["db"]) . "</strong>." : "") . htmlspecialchars($foreign_key["table"]); echo "<td><i>" . implode("</i>, <i>", $foreign_key["source"]) . "</i></td>";
echo '<td><a href="' . htmlspecialchars(strlen($foreign_key["db"]) ? preg_replace('~db=[^&]*~', "db=" . urlencode($foreign_key["db"]), $SELF) : $SELF) . "table=" . urlencode($foreign_key["table"]) . "\">$link</a>(<em>" . implode("</em>, <em>", $foreign_key["target"]) . "</em>)</td>"; $link = (strlen($foreign_key["db"]) ? "<strong>" . htmlspecialchars($foreign_key["db"]) . "</strong>." : "") . htmlspecialchars($foreign_key["table"]);
echo '<td>' . (!strlen($foreign_key["db"]) ? '<a href="' . htmlspecialchars($SELF) . 'foreign=' . urlencode($_GET["table"]) . '&amp;name=' . urlencode($name) . '">' . lang('Alter') . '</a>' : '&nbsp;') . '</td>'; echo '<td><a href="' . htmlspecialchars(strlen($foreign_key["db"]) ? preg_replace('~db=[^&]*~', "db=" . urlencode($foreign_key["db"]), $SELF) : $SELF) . "table=" . urlencode($foreign_key["table"]) . "\">$link</a>(<em>" . implode("</em>, <em>", $foreign_key["target"]) . "</em>)</td>";
echo "</tr>\n"; echo '<td>' . (!strlen($foreign_key["db"]) ? '<a href="' . htmlspecialchars($SELF) . 'foreign=' . urlencode($_GET["table"]) . '&amp;name=' . urlencode($name) . '">' . lang('Alter') . '</a>' : '&nbsp;') . '</td>';
echo "</tr>\n";
}
echo "</table>\n";
} }
echo "</table>\n"; echo '<p><a href="' . htmlspecialchars($SELF) . 'foreign=' . urlencode($_GET["table"]) . '">' . lang('Add foreign key') . "</a></p>\n";
} }
echo '<p><a href="' . htmlspecialchars($SELF) . 'foreign=' . urlencode($_GET["table"]) . '">' . lang('Add foreign key') . "</a></p>\n";
} }
if ($mysql->server_info >= 5) { if ($mysql->server_info >= 5) {