mirror of
https://github.com/vrana/adminer.git
synced 2025-08-11 09:04:02 +02:00
Respect numbers in autocomplete
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
@@ -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";
|
||||
}
|
||||
|
@@ -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';
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user