]> git.joonet.de Git - adminer.git/commitdiff
Search in any column
authorjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Thu, 9 Oct 2008 12:10:28 +0000 (12:10 +0000)
committerjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Thu, 9 Oct 2008 12:10:28 +0000 (12:10 +0000)
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@523 7c3ca157-0c34-0410-bff1-cbf682f78f5c

select.inc.php

index c331aca0dd2a00a006b44ace10a4035108b12fb6..e2736f0418455ca967767d1d3e3c7e9099e3d9be 100644 (file)
@@ -36,14 +36,24 @@ foreach ($indexes as $i => $index) {
        }
 }
 foreach ((array) $_GET["where"] as $val) {
-       if (strlen($val["col"]) && in_array($val["op"], $operators)) {
-               if (ereg('IN$', $val["op"])) {
-                       $in = process_length($val["val"]);
-                       $where[] = (strlen($in) ? idf_escape($val["col"]) . " $val[op] ($in)" : "0");
-               } elseif ($val["op"] == "AGAINST") {
+       if (strlen("$val[col]$val[val]") && in_array($val["op"], $operators)) {
+               if ($val["op"] == "AGAINST") {
                        $where[] = "MATCH (" . idf_escape($val["col"]) . ") AGAINST ('" . $mysql->escape_string($val["val"]) . "' IN BOOLEAN MODE)";
+               } elseif (ereg('IN$', $val["op"]) && !strlen($in = process_length($val["val"]))) {
+                       $where[] = "0";
                } else {
-                       $where[] = idf_escape($val["col"]) . " $val[op]" . (ereg('NULL$', $val["op"]) ? "" : " '" . $mysql->escape_string($val["val"]) . "'");
+                       $cond = " $val[op]" . (ereg('NULL$', $val["op"]) ? "" : (ereg('IN$', $val["op"]) ? " ($in)" : " '" . $mysql->escape_string($val["val"]) . "'")); //! hledá i v číselných hodnotách
+                       if (strlen($val["col"])) {
+                               $where[] = idf_escape($val["col"]) . $cond;
+                       } else {
+                               $cols = array();
+                               foreach ($fields as $name => $field) {
+                                       if (is_numeric($val["val"]) || !ereg('int|float|double|decimal', $field["type"])) {
+                                               $cols[] = $name;
+                                       }
+                               }
+                               $where[] = ($cols ? "(" . implode("$cond OR ", array_map('idf_escape', $cols)) . "$cond)" : "0");
+                       }
                }
        }
 }
@@ -160,7 +170,7 @@ function add_row(field) {
        }
        $i = 0;
        foreach ((array) $_GET["where"] as $val) {
-               if (strlen($val["col"]) && in_array($val["op"], $operators)) {
+               if (strlen("$val[col]$val[val]") && in_array($val["op"], $operators)) {
                        echo "<div><select name='where[$i][col]'><option></option>" . optionlist($columns, $val["col"]) . "</select>";
                        echo "<select name='where[$i][op]' onchange=\"where_change(this);\">" . optionlist($operators, $val["op"]) . "</select>";
                        echo "<input name='where[$i][val]' value=\"" . htmlspecialchars($val["val"]) . "\" /></div>\n";