Permalink
Browse files

Simplify tablesPrint

git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@1135 7c3ca157-0c34-0410-bff1-cbf682f78f5c
  • Loading branch information...
1 parent 09e93de commit df0c4bba956fba4b67de309b651d28c60e79e1cb jakubvrana committed Sep 23, 2009
Showing with 30 additions and 31 deletions.
  1. +16 −17 adminer/include/adminer.inc.php
  2. +14 −14 editor/include/adminer.inc.php
@@ -435,7 +435,7 @@ function processInput($field, $value, $function = "") {
* @return null
*/
function navigation($missing) {
- global $VERSION;
+ global $VERSION, $connection;
?>
<h1>
<a href="http://www.adminer.org/" id="h1"><?php echo $this->name(); ?></a>
@@ -470,28 +470,27 @@ function navigation($missing) {
</p>
</form>
<?php
- $this->tablesPrint($missing);
+ if ($missing != "db" && strlen(DB) && $connection->select_db(DB)) {
+ $tables = get_vals("SHOW TABLES");
+ if (!$tables) {
+ echo "<p class='message'>" . lang('No tables.') . "\n";
+ } else {
+ $this->tablesPrint($tables);
+ }
+ echo '<p><a href="' . h(ME) . 'create=">' . lang('Create new table') . "</a>\n";
+ }
}
}
/** Prints table list in menu
- * @param string can be "db" if there is no database selected
+ * @param array
* @return null
*/
- function tablesPrint($missing) {
- global $connection;
- if ($missing != "db" && strlen(DB) && $connection->select_db(DB)) {
- $result = $connection->query("SHOW TABLES");
- if (!$result->num_rows) {
- echo "<p class='message'>" . lang('No tables.') . "\n";
- } else {
- echo "<p id='tables'>\n";
- while ($row = $result->fetch_row()) {
- echo '<a href="' . h(ME) . 'select=' . urlencode($row[0]) . '">' . lang('select') . '</a> ';
- echo '<a href="' . h(ME) . 'table=' . urlencode($row[0]) . '">' . $this->tableName(array("Name" => $row[0])) . "</a><br>\n"; //! Adminer::tableName may work with full table status
- }
- }
- echo '<p><a href="' . h(ME) . 'create=">' . lang('Create new table') . "</a>\n";
+ function tablesPrint($tables) {
+ echo "<p id='tables'>\n";
+ foreach ($tables as $table) {
+ echo '<a href="' . h(ME) . 'select=' . urlencode($table) . '">' . lang('select') . '</a> ';
+ echo '<a href="' . h(ME) . 'table=' . urlencode($table) . '">' . $this->tableName(array("Name" => $table)) . "</a><br>\n"; //! Adminer::tableName may work with full table status
}
}
@@ -415,23 +415,23 @@ function navigation($missing) {
</p>
</form>
<?php
- $this->tablesPrint($missing);
+ if ($missing != "db") {
+ $table_status = table_status();
+ if (!$table_status) {
+ echo "<p class='message'>" . lang('No tables.') . "\n";
+ } else {
+ $this->tablesPrint($table_status);
+ }
+ }
}
}
- function tablesPrint($missing) {
- if ($missing != "db") {
- $table_status = table_status();
- if (!$table_status) {
- echo "<p class='message'>" . lang('No tables.') . "\n";
- } else {
- echo "<p id='tables'>\n";
- foreach ($table_status as $row) {
- $name = $this->tableName($row);
- if (isset($row["Engine"]) && strlen($name)) { // ignore views and tables without name
- echo "<a href='" . h(ME) . 'select=' . urlencode($row["Name"]) . "'>$name</a><br>\n";
- }
- }
+ function tablesPrint($tables) {
+ echo "<p id='tables'>\n";
+ foreach ($tables as $row) {
+ $name = $this->tableName($row);
+ if (isset($row["Engine"]) && strlen($name)) { // ignore views and tables without name
+ echo "<a href='" . h(ME) . 'select=' . urlencode($row["Name"]) . "'>$name</a><br>\n";
}
}
}

0 comments on commit df0c4bb

Please sign in to comment.