]> git.joonet.de Git - adminer.git/commitdiff
Respect numbers in autocomplete
authorJakub Vrana <jakub@vrana.cz>
Thu, 5 May 2011 05:46:36 +0000 (07:46 +0200)
committerJakub Vrana <jakub@vrana.cz>
Thu, 5 May 2011 05:46:36 +0000 (07:46 +0200)
editor/include/adminer.inc.php
editor/script.inc.php
editor/static/editing.js

index 5df36fcf056ee88e1b748b63b793cff3dc3d0201..903449b488db1108bdddbf8b00659a91110e34e8 100644 (file)
@@ -572,10 +572,10 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5
                        $return = &$this->_values[$table];
                        if (!isset($return)) {
                                $table_status = table_status($table);
-                               $return = ($table_status["Rows"] > 1000
-                                       ? (isset($value) ? $connection->result("SELECT $name FROM " . table($table) . " WHERE $id = " . q($value)) : "")
-                                       : array("" => "") + get_key_vals("SELECT $id, $name FROM " . table($table) . " ORDER BY 2")
-                               );
+                               $return = ($table_status["Rows"] > 1000 ? "" : array("" => "") + get_key_vals("SELECT $id, $name FROM " . table($table) . " ORDER BY 2"));
+                       }
+                       if (!$return && isset($value)) {
+                               return $connection->result("SELECT $name FROM " . table($table) . " WHERE $id = " . q($value));
                        }
                        return $return;
                }
index 1de9ab473efce603395085a7497e448789072157..e1189ef2ec944055d39ec98080057f1874936da9 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 if (list($table, $id, $name) = $adminer->_foreignColumn(column_foreign_keys($_GET["source"]), $_GET["field"])) {
-       $result = $connection->query("SELECT $id, $name FROM " . table($table) . " WHERE $name LIKE " . q("$_GET[value]%") . " ORDER BY 2 LIMIT 11");
+       $result = $connection->query("SELECT $id, $name FROM " . table($table) . " WHERE " . (ereg('^[0-9]+$', $_GET["value"]) ? "$id = $_GET[value] OR " : "") . "$name LIKE " . q("$_GET[value]%") . " ORDER BY 2 LIMIT 11");
        for ($i=0; $i < 10 && ($row = $result->fetch_row()); $i++) {
                echo "<a href='" . h(ME . "edit=" . urlencode($table) . "&where" . urlencode("[" . bracket_escape(idf_unescape($id)) . "]") . "=" . urlencode($row[0])) . "'>" . h($row[1]) . "</a><br>\n";
        }
index e89fc14079e077f149dbc68cb4c7a218c9a97f8b..e12c44f534bf272d5b6afa71b8606266fd652742 100644 (file)
@@ -18,16 +18,17 @@ function whisperClick(event, field) {
 }
 
 function whisper(url, field) {
-       if (field.orig != field.value) {
+       if (field.orig != field.value) { // ignore arrows, Shift, ...
                field.orig = field.value;
+               field.previousSibling.value = field.value; // accept number, reject string
                return ajax(url + encodeURIComponent(field.value), function (xmlhttp) {
-                       if (xmlhttp.status && field.orig == field.value) {
+                       if (xmlhttp.status && field.orig == field.value) { // ignore old responses
                                field.nextSibling.innerHTML = xmlhttp.responseText;
                                field.nextSibling.style.display = '';
                                var a = field.nextSibling.firstChild;
                                if (a && a.firstChild.data == field.value) {
                                        field.previousSibling.value = decodeURIComponent(a.href.replace(/.*=/, ''));
-                                       a.style.fontWeight = 'bold';
+                                       a.className = 'active';
                                }
                        }
                });