mirror of
https://github.com/vrana/adminer.git
synced 2025-08-08 07:36:44 +02:00
Fix global search in all tables
This commit is contained in:
@@ -61,7 +61,7 @@ if ($adminer->homepage()) {
|
||||
echo " <input type='submit' name='search' value='" . lang('Search') . "'>\n";
|
||||
echo "</div></fieldset>\n";
|
||||
if ($_POST["search"] && $_POST["query"] != "") {
|
||||
$_GET["where"][0]["op"] = "LIKE %%";
|
||||
$_GET["where"][0]["op"] = $driver->convertOperator("LIKE %%");
|
||||
search_tables();
|
||||
}
|
||||
}
|
||||
|
@@ -57,6 +57,14 @@ if (isset($_GET["elastic"])) {
|
||||
* @return mixed
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -97,7 +105,9 @@ if (isset($_GET["elastic"])) {
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
function convertOperator($operator) {
|
||||
return $operator == "LIKE %%" ? "should" : $operator;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -268,6 +282,10 @@ if (isset($_GET["elastic"])) {
|
||||
return $return;
|
||||
}
|
||||
|
||||
function limit($query, $where, $limit, $offset = 0, $separator = " ") {
|
||||
return " $query$where" . ($limit !== null ? $separator . "LIMIT $limit" . ($offset ? " OFFSET $offset" : "") : "");
|
||||
}
|
||||
|
||||
function collations() {
|
||||
return array();
|
||||
}
|
||||
|
@@ -142,6 +142,14 @@ function add_driver($id, $name) {
|
||||
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
|
||||
* @param string
|
||||
* @param array
|
||||
|
Reference in New Issue
Block a user