1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-17 12:00:41 +02:00

Respect column type with anywhere comparison

Search LIKE '%%' with text columns

git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@1056 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
jakubvrana
2009-09-01 14:24:08 +00:00
parent 251b39795e
commit 70a3671a09

View File

@@ -201,21 +201,17 @@ ORDER BY ORDINAL_POSITION"); //! requires MySQL 5
function selectSearchProcess($fields, $indexes) { function selectSearchProcess($fields, $indexes) {
$return = array(); $return = array();
foreach ((array) $_GET["where"] as $val) { foreach ((array) $_GET["where"] as $val) {
if (strlen("$val[col]$val[val]")) { $col = $val["col"];
$value = $this->processInput($fields[$val["col"]], $val["val"]); if (strlen("$col$val[val]")) {
$cond = ($value == "NULL" ? " IS" : ($val["op"] == "=" ? " =" : " LIKE")) . " $value"; $conds = array();
if (strlen($val["col"])) { foreach ((strlen($col) ? array($col => $fields[$col]) : $fields) as $name => $field) {
$return[] = idf_escape($val["col"]) . $cond; if (strlen($col) || is_numeric($val["val"]) || !ereg('int|float|double|decimal', $field["type"])) {
} else { $text_type = ereg('char|text|enum|set', $field["type"]);
// find anywhere $value = $this->processInput($field, (strlen($val["val"]) && $text_type && strpos($val["val"], "%") === false ? "%$val[val]%" : $val["val"]));
$cols = array(); $conds[] = idf_escape($name) . ($value == "NULL" ? " IS" : ($val["op"] != "=" && $text_type ? " LIKE" : " =")) . " $value";
foreach ($fields as $name => $field) {
if (is_numeric($val["val"]) || !ereg('int|float|double|decimal', $field["type"])) {
$cols[] = $name;
}
} }
$return[] = ($cols ? "(" . implode("$cond OR ", array_map('idf_escape', $cols)) . "$cond)" : "0");
} }
$return[] = ($conds ? "(" . implode(" OR ", $conds) . ")" : "0");
} }
} }
return $return; return $return;