diff --git a/adminer/drivers/elastic7.inc.php b/plugins/drivers/elastic7.php similarity index 90% rename from adminer/drivers/elastic7.inc.php rename to plugins/drivers/elastic7.php index 16aeabf48..e183a3564 100644 --- a/adminer/drivers/elastic7.inc.php +++ b/plugins/drivers/elastic7.php @@ -1,10 +1,10 @@ _conn->rootQuery($query, $data); if ($print) { - echo $adminer->selectQuery("$query: " . json_encode($data), $start, !$search); + echo adminer()->selectQuery("$query: " . json_encode($data), $start, !$search); } if (empty($search)) { return false; @@ -275,11 +273,9 @@ function convertOperator($operator) { } function connect() { - global $adminer; - $connection = new Min_DB; - list($server, $username, $password) = $adminer->credentials(); + list($server, $username, $password) = adminer()->credentials(); if ($password != "" && $connection->connect($server, $username, "")) { return lang('Database does not support password.'); } @@ -296,9 +292,7 @@ function support($feature) { } function logged_user() { - global $adminer; - - $credentials = $adminer->credentials(); + $credentials = adminer()->credentials(); return $credentials[1]; } @@ -324,9 +318,7 @@ function engines() { } function count_tables($databases) { - global $connection; - - $return = $connection->rootQuery('_aliases'); + $return = connection()->rootQuery('_aliases'); if (empty($return)) { return array( ELASTIC_DB_NAME => 0 @@ -339,9 +331,7 @@ function count_tables($databases) { } function tables_list() { - global $connection; - - $aliases = $connection->rootQuery('_aliases'); + $aliases = connection()->rootQuery('_aliases'); if (empty($aliases)) { return array(); } @@ -360,10 +350,8 @@ function tables_list() { } function table_status($name = "", $fast = false) { - global $connection; - - $stats = $connection->rootQuery('_stats'); - $aliases = $connection->rootQuery('_aliases'); + $stats = connection()->rootQuery('_stats'); + $aliases = connection()->rootQuery('_aliases'); if (empty($stats) || empty($aliases)) { return array(); @@ -428,9 +416,7 @@ function is_view($table_status) { } function error() { - global $connection; - - return h($connection->error); + return h(connection()->error); } function information_schema() { @@ -444,13 +430,11 @@ function indexes($table, $connection2 = null) { } function fields($table) { - global $connection; - $mappings = array(); - $mapping = $connection->rootQuery("_mapping"); + $mapping = connection()->rootQuery("_mapping"); if (!isset($mapping[$table])) { - $aliases = $connection->rootQuery('_aliases'); + $aliases = connection()->rootQuery('_aliases'); foreach ($aliases as $index_name => $index) { foreach ($index["aliases"] as $alias_name => $alias) { @@ -527,32 +511,26 @@ function found_rows($table_status, $where) { } /** Create index - * @param string - * @return mixed - */ + * @param string + * @return mixed + */ function create_database($db) { - global $connection; - - return $connection->rootQuery(urlencode($db), null, 'PUT'); + return connection()->rootQuery(urlencode($db), null, 'PUT'); } /** Remove index - * @param array - * @return mixed - */ + * @param array + * @return mixed + */ function drop_databases($databases) { - global $connection; - - return $connection->rootQuery(urlencode(implode(',', $databases)), null, 'DELETE'); + return connection()->rootQuery(urlencode(implode(',', $databases)), null, 'DELETE'); } /** Alter type - * @param array - * @return mixed - */ + * @param array + * @return mixed + */ function alter_table($table, $name, $fields, $foreign, $comment, $engine, $collation, $auto_increment, $partitioning) { - global $connection; - $properties = array(); foreach ($fields as $f) { $field_name = trim($f[1][0]); @@ -566,28 +544,24 @@ function alter_table($table, $name, $fields, $foreign, $comment, $engine, $colla $properties = array('properties' => $properties); } - return $connection->query("_mapping/{$name}", $properties, 'PUT'); + return connection()->query("_mapping/{$name}", $properties, 'PUT'); } /** Drop types - * @param array - * @return bool - */ + * @param array + * @return bool + */ function drop_tables($tables) { - global $connection; - $return = true; foreach ($tables as $table) { //! convert to bulk api - $return = $return && $connection->query(urlencode($table), null, 'DELETE'); + $return = $return && connection()->query(urlencode($table), null, 'DELETE'); } return $return; } function last_id() { - global $connection; - - return $connection->last_id; + return connection()->last_id; } function driver_config() {