mirror of
https://github.com/vrana/adminer.git
synced 2026-04-12 23:48:12 +02:00
Move connect() to Driver
This commit is contained in:
@@ -110,6 +110,16 @@ if (isset($_GET["elastic"])) {
|
||||
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(
|
||||
@@ -283,20 +293,6 @@ if (isset($_GET["elastic"])) {
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user