From a3d2266a9c9e7e9bff89bf26497bdcb12a0cb9d5 Mon Sep 17 00:00:00 2001 From: jakubvrana Date: Tue, 28 Jul 2009 11:04:49 +0000 Subject: [PATCH] Order by first index in Editor by default Flush before SHOW DATABASES by default git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@923 7c3ca157-0c34-0410-bff1-cbf682f78f5c --- adminer/include/adminer.inc.php | 2 -- adminer/include/mysql.inc.php | 6 +++++- adminer/select.inc.php | 9 ++------- editor/include/adminer.inc.php | 15 ++++++++++----- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/adminer/include/adminer.inc.php b/adminer/include/adminer.inc.php index e07afd73..f07cb2c8 100644 --- a/adminer/include/adminer.inc.php +++ b/adminer/include/adminer.inc.php @@ -423,8 +423,6 @@ class Adminer { function navigation($missing) { global $SELF, $dbh; if ($missing != "auth") { - ob_flush(); - flush(); $databases = get_databases(); ?>
diff --git a/adminer/include/mysql.inc.php b/adminer/include/mysql.inc.php index a4862d94..8533eae7 100644 --- a/adminer/include/mysql.inc.php +++ b/adminer/include/mysql.inc.php @@ -152,11 +152,15 @@ function connect() { return $dbh->error; } -function get_databases() { +function get_databases($flush = true) { // SHOW DATABASES can take a very long time so it is cached $return = &$_SESSION["databases"][$_GET["server"]]; if (!isset($return)) { $return = get_vals("SHOW DATABASES"); + if ($flush) { + ob_flush(); + flush(); + } } return $return; } diff --git a/adminer/select.inc.php b/adminer/select.inc.php index f7ca86a5..166545c8 100644 --- a/adminer/select.inc.php +++ b/adminer/select.inc.php @@ -32,12 +32,7 @@ $group_by = ($group && count($group) < count($select) ? " GROUP BY " . implode(" if ($_POST && !$error) { $where_check = "(" . implode(") OR (", array_map('where_check', (array) $_POST["check"])) . ")"; - $primary = null; // empty array means that all primary fields are selected - foreach ($indexes as $index) { - if ($index["type"] == "PRIMARY") { - $primary = ($select ? array_flip($index["columns"]) : array()); - } - } + $primary = ($indexes["PRIMARY"] ? ($select ? array_flip($indexes["PRIMARY"]["columns"]) : array()) : null); // empty array means that all primary fields are selected foreach ($select as $key => $val) { $val = $_GET["columns"][$key]; if (!$val["fun"]) { @@ -189,7 +184,7 @@ if (!$columns) { if (strlen($name)) { $order++; $names[$key] = $name; - echo '' . apply_sql_function($val["fun"], $name) . ""; + echo '' . apply_sql_function($val["fun"], $name) . ""; //! order by function can collide with column name like min(`id`) } next($select); } diff --git a/editor/include/adminer.inc.php b/editor/include/adminer.inc.php index bb968cd9..9d8db8a5 100644 --- a/editor/include/adminer.inc.php +++ b/editor/include/adminer.inc.php @@ -10,7 +10,7 @@ class Adminer { } function database() { - $dbs = get_databases(); + $dbs = get_databases(false); return (count($dbs) == 1 ? $dbs[0] : (count($dbs) == 2 && information_schema($dbs[0]) ? $dbs[1] : 'test')); } @@ -211,10 +211,15 @@ ORDER BY ORDINAL_POSITION"); //! requires MySQL 5 } function selectOrderProcess($columns, $select, $indexes) { - return ($_GET["order"] - ? array(idf_escape($_GET["order"][0]) . (isset($_GET["desc"][0]) ? " DESC" : "")) - : $indexes[$_GET["index_order"]]["columns"] - ); + if ($_GET["order"]) { + return array(idf_escape($_GET["order"][0]) . (isset($_GET["desc"][0]) ? " DESC" : "")); + } + if ($_GET["index_order"]) { + return $indexes[$_GET["index_order"]]["columns"]; + } + unset($indexes["PRIMARY"]); + $index = reset($indexes); + return ($index ? $index["columns"] : array()); } function selectLimitProcess() {