]> git.joonet.de Git - adminer.git/commitdiff
Order by first index in Editor by default
authorjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Tue, 28 Jul 2009 11:04:49 +0000 (11:04 +0000)
committerjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Tue, 28 Jul 2009 11:04:49 +0000 (11:04 +0000)
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
adminer/include/mysql.inc.php
adminer/select.inc.php
editor/include/adminer.inc.php

index e07afd73909720e84be1e48fe4499511af689116..f07cb2c8599e9e68145b196a4963ed3629e73379 100644 (file)
@@ -423,8 +423,6 @@ class Adminer {
        function navigation($missing) {
                global $SELF, $dbh;
                if ($missing != "auth") {
-                       ob_flush();
-                       flush();
                        $databases = get_databases();
                        ?>
 <form action="" method="post">
index a4862d94050c9c5cc51b0a582c75b600195eb24f..8533eae7fe95feed9b93328d83b36df512fae686 100644 (file)
@@ -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;
 }
index f7ca86a51416ad76c585e0b3686523f14ddabd0e..166545c897f2d2d53005c8948d4533510dcca2ff 100644 (file)
@@ -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 '<th><a href="' . htmlspecialchars(remove_from_uri('(order|desc)[^=]*') . '&order%5B0%5D=' . urlencode($key) . ($_GET["order"] == array($key) && !$_GET["desc"][0] ? '&desc%5B0%5D=1' : '')) . '">' . apply_sql_function($val["fun"], $name) . "</a>";
+                                       echo '<th><a href="' . htmlspecialchars(remove_from_uri('(order|desc)[^=]*') . '&order%5B0%5D=' . urlencode($key) . ($_GET["order"] == array($key) && !$_GET["desc"][0] ? '&desc%5B0%5D=1' : '')) . '">' . apply_sql_function($val["fun"], $name) . "</a>"; //! order by function can collide with column name like min(`id`)
                                }
                                next($select);
                        }
index bb968cd949912b12a9fa01d65b6f598a0d9c820c..9d8db8a5551397a254a1b2817ca2c44ccd90c280 100644 (file)
@@ -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() {