From df0c4bba956fba4b67de309b651d28c60e79e1cb Mon Sep 17 00:00:00 2001 From: jakubvrana Date: Wed, 23 Sep 2009 15:01:17 +0000 Subject: [PATCH] Simplify tablesPrint git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@1135 7c3ca157-0c34-0410-bff1-cbf682f78f5c --- adminer/include/adminer.inc.php | 33 ++++++++++++++++----------------- editor/include/adminer.inc.php | 28 ++++++++++++++-------------- 2 files changed, 30 insertions(+), 31 deletions(-) diff --git a/adminer/include/adminer.inc.php b/adminer/include/adminer.inc.php index ebe8969d..6896a7cf 100644 --- a/adminer/include/adminer.inc.php +++ b/adminer/include/adminer.inc.php @@ -435,7 +435,7 @@ class Adminer { * @return null */ function navigation($missing) { - global $VERSION; + global $VERSION, $connection; ?>

name(); ?> @@ -470,28 +470,27 @@ class Adminer {

tablesPrint($missing); + if ($missing != "db" && strlen(DB) && $connection->select_db(DB)) { + $tables = get_vals("SHOW TABLES"); + if (!$tables) { + echo "

" . lang('No tables.') . "\n"; + } else { + $this->tablesPrint($tables); + } + echo '

' . lang('Create new table') . "\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 "

" . lang('No tables.') . "\n"; - } else { - echo "

\n"; - while ($row = $result->fetch_row()) { - echo '' . lang('select') . ' '; - echo '' . $this->tableName(array("Name" => $row[0])) . "
\n"; //! Adminer::tableName may work with full table status - } - } - echo '

' . lang('Create new table') . "\n"; + function tablesPrint($tables) { + echo "

\n"; + foreach ($tables as $table) { + echo '' . lang('select') . ' '; + echo '' . $this->tableName(array("Name" => $table)) . "
\n"; //! Adminer::tableName may work with full table status } } diff --git a/editor/include/adminer.inc.php b/editor/include/adminer.inc.php index 52e0d570..97fc74da 100644 --- a/editor/include/adminer.inc.php +++ b/editor/include/adminer.inc.php @@ -415,23 +415,23 @@ ORDER BY ORDINAL_POSITION"); //! requires MySQL 5

tablesPrint($missing); + if ($missing != "db") { + $table_status = table_status(); + if (!$table_status) { + echo "

" . lang('No tables.') . "\n"; + } else { + $this->tablesPrint($table_status); + } + } } } - function tablesPrint($missing) { - if ($missing != "db") { - $table_status = table_status(); - if (!$table_status) { - echo "

" . lang('No tables.') . "\n"; - } else { - echo "

\n"; - foreach ($table_status as $row) { - $name = $this->tableName($row); - if (isset($row["Engine"]) && strlen($name)) { // ignore views and tables without name - echo "$name
\n"; - } - } + function tablesPrint($tables) { + echo "

\n"; + foreach ($tables as $row) { + $name = $this->tableName($row); + if (isset($row["Engine"]) && strlen($name)) { // ignore views and tables without name + echo "$name
\n"; } } } -- 2.39.5