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

Fix global search in all tables

This commit is contained in:
Peter Knut
2021-04-05 00:13:07 +02:00
committed by Jakub Vrana
parent 1270748f74
commit dc1ad9e8ed
3 changed files with 28 additions and 2 deletions

View File

@@ -61,7 +61,7 @@ if ($adminer->homepage()) {
echo " <input type='submit' name='search' value='" . lang('Search') . "'>\n"; echo " <input type='submit' name='search' value='" . lang('Search') . "'>\n";
echo "</div></fieldset>\n"; echo "</div></fieldset>\n";
if ($_POST["search"] && $_POST["query"] != "") { if ($_POST["search"] && $_POST["query"] != "") {
$_GET["where"][0]["op"] = "LIKE %%"; $_GET["where"][0]["op"] = $driver->convertOperator("LIKE %%");
search_tables(); search_tables();
} }
} }

View File

@@ -57,6 +57,14 @@ if (isset($_GET["elastic"])) {
* @return mixed * @return mixed
*/ */
function query($path, $content = array(), $method = 'GET') { function query($path, $content = array(), $method = 'GET') {
// Support for global search through all tables
if ($path != "" && $path[0] == "S" && preg_match('/SELECT 1 FROM ([^ ]+) WHERE (.+) LIMIT ([0-9]+)/', $path, $matches)) {
global $driver;
$where = explode(" AND ", $matches[2]);
return $driver->select($matches[1], array("*"), $where, null, array(), $matches[3]);
}
return $this->rootQuery(($this->_db != "" ? "$this->_db/" : "/") . ltrim($path, '/'), $content, $method); return $this->rootQuery(($this->_db != "" ? "$this->_db/" : "/") . ltrim($path, '/'), $content, $method);
} }
@@ -97,7 +105,9 @@ if (isset($_GET["elastic"])) {
} }
function fetch_row() { function fetch_row() {
return array_values($this->fetch_assoc()); $row = $this->fetch_assoc();
return $row ? array_values($row) : false;
} }
} }
@@ -231,6 +241,10 @@ if (isset($_GET["elastic"])) {
} }
return $this->_conn->affected_rows; return $this->_conn->affected_rows;
} }
function convertOperator($operator) {
return $operator == "LIKE %%" ? "should" : $operator;
}
} }
@@ -268,6 +282,10 @@ if (isset($_GET["elastic"])) {
return $return; return $return;
} }
function limit($query, $where, $limit, $offset = 0, $separator = " ") {
return " $query$where" . ($limit !== null ? $separator . "LIMIT $limit" . ($offset ? " OFFSET $offset" : "") : "");
}
function collations() { function collations() {
return array(); return array();
} }

View File

@@ -142,6 +142,14 @@ function add_driver($id, $name) {
return $idf; return $idf;
} }
/** Convert operator so it can be used in search
* @param string $operator
* @return string
*/
function convertOperator($operator) {
return $operator;
}
/** Convert value returned by database to actual value /** Convert value returned by database to actual value
* @param string * @param string
* @param array * @param array