public array $generated = array("PERSISTED", "VIRTUAL");
public string $onActions = "NO ACTION|CASCADE|SET NULL|SET DEFAULT";
+ static function connect(?string $server, string $username, string $password) {
+ if ($server == "") {
+ $server = "localhost:1433";
+ }
+ return parent::connect($server, $username, $password);
+ }
+
function __construct(Db $connection) {
parent::__construct($connection);
$this->types = array( //! use sys.types
return ($_GET["ns"] != "" ? idf_escape($_GET["ns"]) . "." : "") . idf_escape($idf);
}
- function connect($credentials) {
- $connection = new Db;
- if ($credentials[0] == "") {
- $credentials[0] = "localhost:1433";
- }
- return ($connection->attach($credentials[0], $credentials[1], $credentials[2]) ?: $connection);
- }
-
function get_databases($flush) {
return get_vals("SELECT name FROM sys.databases WHERE name NOT IN ('master', 'tempdb', 'model', 'msdb')");
}
/** @var list<string> */ public array $functions = array("char_length", "date", "from_unixtime", "lower", "round", "floor", "ceil", "sec_to_time", "time_to_sec", "upper");
/** @var list<string> */ public array $grouping = array("avg", "count", "count distinct", "group_concat", "max", "min", "sum");
+ static function connect(?string $server, string $username, string $password) {
+ $connection = parent::connect($server, $username, $password);
+ if (is_string($connection)) {
+ if (function_exists('iconv') && !is_utf8($connection) && strlen($s = iconv("windows-1250", "utf-8", $connection)) > strlen($connection)) { // windows-1250 - most common Windows encoding
+ $connection = $s;
+ }
+ return $connection;
+ }
+ $connection->set_charset(charset($connection));
+ $connection->query("SET sql_quote_show_create = 1, autocommit = 1");
+ $connection->flavor = (preg_match('~MariaDB~', $connection->server_info) ? 'maria' : 'mysql');
+ add_driver(DRIVER, ($connection->flavor == 'maria' ? "MariaDB" : "MySQL"));
+ return $connection;
+ }
+
function __construct(Db $connection) {
parent::__construct($connection);
$this->types = array(
return idf_escape($idf);
}
- /** Connect to the database
- * @param array{?string, string, string} $credentials [$server, $username, $password]
- * @return string|Db string for error
- */
- function connect(array $credentials) {
- $connection = new Db;
- $error = $connection->attach($credentials[0], $credentials[1], $credentials[2]);
- if ($error) {
- if (function_exists('iconv') && !is_utf8($error) && strlen($s = iconv("windows-1250", "utf-8", $error)) > strlen($error)) { // windows-1250 - most common Windows encoding
- $error = $s;
- }
- return $error;
- }
- $connection->set_charset(charset($connection));
- $connection->query("SET sql_quote_show_create = 1, autocommit = 1");
- $connection->flavor = (preg_match('~MariaDB~', $connection->server_info) ? 'maria' : 'mysql');
- add_driver(DRIVER, ($connection->flavor == 'maria' ? "MariaDB" : "MySQL"));
- return $connection;
- }
-
/** Get cached list of databases
* @return list<string>
*/
return idf_escape($idf);
}
- function connect($credentials) {
- $connection = new Db;
- return ($connection->attach($credentials[0], $credentials[1], $credentials[2]) ?: $connection);
- }
-
function get_databases($flush) {
return get_vals(
"SELECT DISTINCT tablespace_name FROM (
public array $functions = array("char_length", "lower", "round", "to_hex", "to_timestamp", "upper");
public array $grouping = array("avg", "count", "count distinct", "max", "min", "sum");
+ static function connect(?string $server, string $username, string $password) {
+ $connection = parent::connect($server, $username, $password);
+ if (is_string($connection)) {
+ return $connection;
+ }
+ if (min_version(9, 0, $connection)) {
+ $connection->query("SET application_name = 'Adminer'");
+ }
+ $version = get_val("SELECT version()", 0, $connection);
+ $connection->flavor = (preg_match('~CockroachDB~', $version) ? 'cockroach' : '');
+ $connection->server_info = preg_replace('~^\D*([\d.]+[-\w]*).*~', '\1', $version);
+ if ($connection->flavor == 'cockroach') { // we don't use "PostgreSQL / CockroachDB" by default because it's too long
+ add_driver(DRIVER, "CockroachDB");
+ }
+ return $connection;
+ }
+
function __construct(Db $connection) {
parent::__construct($connection);
$this->types = array( //! arrays
return idf_escape($idf);
}
- function connect($credentials) {
- $connection = new Db;
- $error = $connection->attach($credentials[0], $credentials[1], $credentials[2]);
- if ($error) {
- return $error;
- }
- if (min_version(9, 0, $connection)) {
- $connection->query("SET application_name = 'Adminer'");
- }
- $version = get_val("SELECT version()", 0, $connection);
- $connection->flavor = (preg_match('~CockroachDB~', $version) ? 'cockroach' : '');
- $connection->server_info = preg_replace('~^\D*([\d.]+[-\w]*).*~', '\1', $version);
- if ($connection->flavor == 'cockroach') { // we don't use "PostgreSQL / CockroachDB" by default because it's too long
- add_driver(DRIVER, "CockroachDB");
- }
- return $connection;
- }
-
function get_databases($flush) {
return get_vals("SELECT datname FROM pg_database
WHERE datallowconn = TRUE AND has_database_privilege(datname, 'CONNECT')
public array $functions = array("hex", "length", "lower", "round", "unixepoch", "upper");
public array $grouping = array("avg", "count", "count distinct", "group_concat", "max", "min", "sum");
+ static function connect(?string $server, string $username, string $password) {
+ if ($password != "") {
+ return lang('Database does not support password.');
+ }
+ return parent::connect(":memory:", "", "");
+ }
+
function __construct(Db $connection) {
parent::__construct($connection);
if (min_version(3.31, 0, $connection)) {
return idf_escape($idf);
}
- function connect($credentials) {
- list(, , $password) = $credentials;
- if ($password != "") {
- return lang('Database does not support password.');
- }
- $connection = new Db;
- return ($connection->attach(":memory:", "", "") ?: $connection);
- }
-
function get_databases($flush) {
return array();
}
public string $enumLength = "'(?:''|[^'\\\\]|\\\\.)*'"; // regular expression for parsing enum lengths
/** @var list<string> */ public array $generated = array(); // allowed types of generated columns
+ /** Connect to the database
+ * @return Db|string string for error
+ */
+ static function connect(?string $server, string $username, string $password) {
+ $connection = new Db;
+ return ($connection->attach($server, $username, $password) ?: $connection);
+ }
+
/** Create object for performing database operations */
function __construct(Db $connection) {
$this->conn = $connection;
return Driver::$instance;
}
+/** Connect to the database
+* @param array{?string, string, string} $credentials [$server, $username, $password]
+* @return Db|string string for error
+*/
+function connect(array $credentials) {
+ return driver()->connect($credentials[0], $credentials[1], $credentials[2]);
+}
+
/** Unescape database identifier
* @param string $idf text inside ``
*/
public array $operators = array("=", "<", ">", "<=", ">=", "!=", "~", "!~", "LIKE", "LIKE %%", "IN", "IS NULL", "NOT LIKE", "NOT IN", "IS NOT NULL", "SQL");
public array $grouping = array("avg", "count", "count distinct", "max", "min", "sum");
+ static function connect(?string $server, string $username, string $password) {
+ if (!preg_match('~^(https?://)?[-a-z\d.]+(:\d+)?$~', $server)) {
+ return lang('Invalid server.');
+ }
+ return parent::connect($server, $username, $password);
+ }
+
function __construct(Db $connection) {
parent::__construct($connection);
$this->types = array( //! arrays
return apply_queries("DROP TABLE", $tables);
}
- function connect($credentials) {
- $connection = new Db;
- list($server, $username, $password) = $credentials;
- if (!preg_match('~^(https?://)?[-a-z\d.]+(:\d+)?$~', $server)) {
- return lang('Invalid server.');
- }
- return ($connection->attach($server, $username, $password) ?: $connection);
- }
-
function get_databases($flush) {
$result = get_rows('SHOW DATABASES');
public array $insertFunctions = array("json");
public array $operators = array("=", "must", "should", "must_not");
+ static function connect(?string $server, string $username, string $password) {
+ if (!preg_match('~^(https?://)?[-a-z\d.]+(:\d+)?$~', $server)) {
+ return lang('Invalid server.');
+ }
+ if ($password != "" && is_object(parent::connect($server, $username, ""))) {
+ return lang('Database does not support password.');
+ }
+ return parent::connect($server, $username, $password);
+ }
+
function __construct(Db $connection) {
parent::__construct($connection);
$this->types = array(
}
}
- function connect($credentials) {
- $connection = new Db;
-
- list($server, $username, $password) = $credentials;
- if (!preg_match('~^(https?://)?[-a-z\d.]+(:\d+)?$~', $server)) {
- return lang('Invalid server.');
- }
- if ($password != "" && $connection->attach($server, $username, "")) {
- return lang('Database does not support password.');
- }
-
- return ($connection->attach($server, $username, $password) ?: $connection);
- }
-
function support($feature) {
return preg_match("~table|columns~", $feature);
}
return idf_escape($idf);
}
- function connect($credentials) {
- $connection = new Db;
- return ($connection->attach($credentials[0], $credentials[1], $credentials[2]) ?: $connection);
- }
-
function get_databases($flush) {
return array("domain");
}
return connection()->expunge();
}
- function connect($credentials) {
- $connection = new Db;
- return ($connection->attach($credentials[0], $credentials[1], $credentials[2]) ?: $connection);
- }
-
function support($feature) {
return false;
}
public $primary = "_id";
+ static function connect(?string $server, string $username, string $password) {
+ if ($server == "") {
+ $server = "localhost:27017";
+ }
+ return parent::connect($server, $username, $password);
+ }
+
function select(string $table, array $select, array $where, array $group, array $order = array(), $limit = 1, ?int $page = 0, bool $print = false) {
$select = ($select == array("*")
? array()
return $credentials[1];
}
- function connect($credentials) {
- $connection = new Db;
- list($server, $username, $password) = $credentials;
- if ($server == "") {
- $server = "localhost:27017";
- }
- return ($connection->attach($server, $username, $password) ?: $connection);
- }
-
function alter_indexes($table, $alter) {
foreach ($alter as $val) {
list($type, $name, $set) = $val;
public $primary = "itemName()";
+ static function connect(?string $server, string $username, string $password) {
+ if (!preg_match('~^(https?://)?[-a-z\d.]+(:\d+)?$~', $server)) {
+ return lang('Invalid server.');
+ }
+ if ($password != "") {
+ return lang('Database does not support password.');
+ }
+ return parent::connect($server, $username, $password);
+ }
+
private function chunkRequest($ids, $action, $params, $expand = array()) {
foreach (array_chunk($ids, 25) as $chunk) {
$params2 = $params;
- function connect($credentials) {
- list($host, , $password) = $credentials;
- if (!preg_match('~^(https?://)?[-a-z\d.]+(:\d+)?$~', $host)) {
- return lang('Invalid server.');
- }
- if ($password != "") {
- return lang('Database does not support password.');
- }
- return new Db;
- }
-
function support($feature) {
return preg_match('~sql~', $feature);
}