Search operators

git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@1148 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
jakubvrana 2009-09-25 13:48:00 +00:00
parent 6b30cfa769
commit 83e8bac503
2 changed files with 5 additions and 1 deletions

View file

@ -5,6 +5,7 @@ Display whitespace in texts (bug #2858042)
Display number of manipulated rows in JS confirm
E-mail attachments (Editor)
Optional year in date (Editor)
Search operators (Editor)
Move <h1> to $adminer->navigation (customization)
Rename get_dbh to connection (customization)

View file

@ -1,5 +1,6 @@
<?php
class Adminer {
var $operators = array("<=", ">=");
function name() {
return lang('Editor');
@ -167,11 +168,13 @@ ORDER BY ORDINAL_POSITION"); //! requires MySQL 5
foreach ((array) $_GET["where"] as $val) {
if (strlen("$val[col]$val[val]")) {
echo "<div><select name='where[$i][col]'><option value=''>" . lang('(anywhere)') . optionlist($columns, $val["col"], true) . "</select>";
echo "<select name='where[$i][op]'><option>" . optionlist($this->operators, $val["op"]) . "</select>";
echo "<input name='where[$i][val]' value='" . h($val["val"]) . "'></div>\n";
$i++;
}
}
echo "<div><select name='where[$i][col]' onchange='select_add_row(this);'><option value=''>" . lang('(anywhere)') . optionlist($columns, null, true) . "</select>";
echo "<select name='where[$i][op]'><option>" . optionlist($this->operators) . "</select>";
echo "<input name='where[$i][val]'></div>\n";
echo "</div></fieldset>\n";
}
@ -238,7 +241,7 @@ ORDER BY ORDINAL_POSITION"); //! requires MySQL 5
if (strlen($col) || is_numeric($val["val"]) || !ereg('int|float|double|decimal', $field["type"])) {
$text_type = ereg('char|text|enum|set', $field["type"]);
$value = $this->processInput($field, (strlen($val["val"]) && $text_type && strpos($val["val"], "%") === false ? "%$val[val]%" : $val["val"]));
$conds[] = idf_escape($name) . ($value == "NULL" ? " IS" : ($val["op"] != "=" && $text_type ? " LIKE" : " =")) . " $value";
$conds[] = idf_escape($name) . (in_array($val["op"], $this->operators) ? " $val[op]" : ($value == "NULL" ? " IS" : ($val["op"] != "=" && $text_type ? " LIKE" : " ="))) . " $value";
}
}
$return[] = ($conds ? "(" . implode(" OR ", $conds) . ")" : "0");