mirror of
https://github.com/vrana/adminer.git
synced 2025-08-16 03:24:01 +02:00
Move connect() to Driver
This commit is contained in:
@@ -30,6 +30,14 @@ abstract class SqlDriver {
|
||||
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;
|
||||
|
@@ -24,6 +24,14 @@ function driver(): Driver {
|
||||
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 ``
|
||||
*/
|
||||
|
Reference in New Issue
Block a user