diff --git a/adminer/create.inc.php b/adminer/create.inc.php index b950771d..1d881fff 100644 --- a/adminer/create.inc.php +++ b/adminer/create.inc.php @@ -191,7 +191,7 @@ edit_fields($row["fields"], $collations, "TABLE", $foreign_keys, $comments); " . lang('Comment') . "" . script("qsl('input').onclick = function () { columnShow(this.checked, 6); toggle('Comment'); if (this.checked) this.form['Comment'].focus(); };") - . ' ' + . ' ' : '') ; ?>
diff --git a/adminer/drivers/mysql.inc.php b/adminer/drivers/mysql.inc.php
index 4e952731..4ed06b05 100644
--- a/adminer/drivers/mysql.inc.php
+++ b/adminer/drivers/mysql.inc.php
@@ -325,11 +325,10 @@ if (!defined("DRIVER")) {
* @return array
*/
function get_databases($flush) {
- global $connection;
// SHOW DATABASES can take a very long time so it is cached
$return = get_session("dbs");
if ($return === null) {
- $query = ($connection->server_info >= 5
+ $query = (min_version(5)
? "SELECT SCHEMA_NAME FROM information_schema.SCHEMATA"
: "SHOW DATABASES"
); // SHOW DATABASES can be disabled by skip_show_database
@@ -405,8 +404,7 @@ if (!defined("DRIVER")) {
* @return array array($name => $type)
*/
function tables_list() {
- global $connection;
- return get_key_vals($connection->server_info >= 5
+ return get_key_vals(min_version(5)
? "SELECT TABLE_NAME, TABLE_TYPE FROM information_schema.TABLES WHERE TABLE_SCHEMA = DATABASE() ORDER BY TABLE_NAME"
: "SHOW TABLES"
);
@@ -430,9 +428,8 @@ if (!defined("DRIVER")) {
* @return array array($name => array("Name" => , "Engine" => , "Comment" => , "Oid" => , "Rows" => , "Collation" => , "Auto_increment" => , "Data_length" => , "Index_length" => , "Data_free" => )) or only inner array with $name
*/
function table_status($name = "", $fast = false) {
- global $connection;
$return = array();
- foreach (get_rows($fast && $connection->server_info >= 5
+ foreach (get_rows($fast && min_version(5)
? "SELECT TABLE_NAME AS Name, ENGINE AS Engine, TABLE_COMMENT AS Comment FROM information_schema.TABLES WHERE TABLE_SCHEMA = DATABASE() " . ($name != "" ? "AND TABLE_NAME = " . q($name) : "ORDER BY Name")
: "SHOW TABLE STATUS" . ($name != "" ? " LIKE " . q(addcslashes($name, "%_\\")) : "")
) as $row) {
@@ -464,9 +461,8 @@ if (!defined("DRIVER")) {
* @return bool
*/
function fk_support($table_status) {
- global $connection;
return preg_match('~InnoDB|IBMDB2I~i', $table_status["Engine"])
- || (preg_match('~NDB~i', $table_status["Engine"]) && $connection->server_info >= 5.6);
+ || (preg_match('~NDB~i', $table_status["Engine"]) && min_version(5.6));
}
/** Get information about fields
@@ -573,9 +569,8 @@ if (!defined("DRIVER")) {
* @return bool
*/
function information_schema($db) {
- global $connection;
- return ($connection->server_info >= 5 && $db == "information_schema")
- || ($connection->server_info >= 5.5 && $db == "performance_schema");
+ return (min_version(5) && $db == "information_schema")
+ || (min_version(5.5) && $db == "performance_schema");
}
/** Get escaped error message
@@ -872,7 +867,7 @@ if (!defined("DRIVER")) {
* @return Min_Result
*/
function explain($connection, $query) {
- return $connection->query("EXPLAIN " . ($connection->server_info >= 5.1 ? "PARTITIONS " : "") . $query);
+ return $connection->query("EXPLAIN " . (min_version(5.1) ? "PARTITIONS " : "") . $query);
}
/** Get approximate number of rows
@@ -982,7 +977,6 @@ if (!defined("DRIVER")) {
* @return string
*/
function convert_field($field) {
- global $connection;
if (preg_match("~binary~", $field["type"])) {
return "HEX(" . idf_escape($field["field"]) . ")";
}
@@ -990,7 +984,7 @@ if (!defined("DRIVER")) {
return "BIN(" . idf_escape($field["field"]) . " + 0)"; // + 0 is required outside MySQLnd
}
if (preg_match("~geometry|point|linestring|polygon~", $field["type"])) {
- return ($connection->server_info >= 8 ? "ST_" : "") . "AsWKT(" . idf_escape($field["field"]) . ")";
+ return (min_version(8) ? "ST_" : "") . "AsWKT(" . idf_escape($field["field"]) . ")";
}
}
@@ -1017,8 +1011,7 @@ if (!defined("DRIVER")) {
* @return bool
*/
function support($feature) {
- global $connection;
- return !preg_match("~scheme|sequence|type|view_trigger|materializedview" . ($connection->server_info < 5.1 ? "|event|partitioning" . ($connection->server_info < 5 ? "|routine|trigger|view" : "") : "") . "~", $feature);
+ return !preg_match("~scheme|sequence|type|view_trigger|materializedview" . (min_version(5.1) ? "" : "|event|partitioning" . (min_version(5) ? "" : "|routine|trigger|view")) . "~", $feature);
}
function kill_process($val) {
diff --git a/adminer/drivers/pgsql.inc.php b/adminer/drivers/pgsql.inc.php
index 620a3446..78c71833 100644
--- a/adminer/drivers/pgsql.inc.php
+++ b/adminer/drivers/pgsql.inc.php
@@ -713,8 +713,7 @@ AND typelem = 0"
}
function process_list() {
- global $connection;
- return get_rows("SELECT * FROM pg_stat_activity ORDER BY " . ($connection->server_info < 9.2 ? "procpid" : "pid"));
+ return get_rows("SELECT * FROM pg_stat_activity ORDER BY " . (min_version(9.2) ? "pid" : "procpid"));
}
function show_status() {
@@ -728,8 +727,7 @@ AND typelem = 0"
}
function support($feature) {
- global $connection;
- return preg_match('~^(database|table|columns|sql|indexes|comment|view|' . ($connection->server_info >= 9.3 ? 'materializedview|' : '') . 'scheme|processlist|sequence|trigger|type|variables|drop_col|kill|dump)$~', $feature); //! routine|
+ return preg_match('~^(database|table|columns|sql|indexes|comment|view|' . (min_version(9.3) ? 'materializedview|' : '') . 'scheme|processlist|sequence|trigger|type|variables|drop_col|kill|dump)$~', $feature); //! routine|
}
function kill_process($val) {
diff --git a/adminer/include/editing.inc.php b/adminer/include/editing.inc.php
index 94197287..23a174d0 100644
--- a/adminer/include/editing.inc.php
+++ b/adminer/include/editing.inc.php
@@ -235,7 +235,7 @@ function type_class($type) {
* @return null
*/
function edit_fields($fields, $collations, $type = "TABLE", $foreign_keys = array(), $comments = false) {
- global $connection, $inout;
+ global $inout;
$fields = array_values($fields);
?>
@@ -274,7 +274,7 @@ function edit_fields($fields, $collations, $type = "TABLE", $foreign_keys = arra
" aria-labelledby="label-default">
-" : ""); ?>
+" : ""); ?>
";
diff --git a/adminer/include/functions.inc.php b/adminer/include/functions.inc.php
index 2169582b..607a56e5 100644
--- a/adminer/include/functions.inc.php
+++ b/adminer/include/functions.inc.php
@@ -93,7 +93,7 @@ function min_version($version, $maria_db = "") {
* @return string
*/
function charset($connection) {
- return (version_compare($connection->server_info, "5.5.3") >= 0 ? "utf8mb4" : "utf8"); // SHOW CHARSET would require an extra query
+ return (min_version("5.5.3") ? "utf8mb4" : "utf8"); // SHOW CHARSET would require an extra query
}
/** Return