1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-12 01:24:17 +02:00

Db: Unify connection error handling

This commit is contained in:
Jakub Vrana
2025-03-28 22:00:53 +01:00
parent d5bba383ea
commit 29339c5223
13 changed files with 95 additions and 123 deletions

View File

@@ -14,17 +14,15 @@ if (isset($_GET["firebird"])) {
class Db extends SqlDb {
public string $extension = "Firebird", $_link;
function connect(string $server, string $username, string $password): bool {
function attach(?string $server, string $username, string $password): string {
$this->_link = ibase_connect($server, $username, $password);
if ($this->_link) {
$url_parts = explode(':', $server);
$service_link = ibase_service_attach($url_parts[0], $username, $password);
$this->server_info = ibase_server_info($service_link, IBASE_SVC_SERVER_VERSION);
} else {
$this->errno = ibase_errcode();
$this->error = ibase_errmsg();
return '';
}
return (bool) $this->_link;
return ibase_errmsg();
}
function quote(string $string): string {
@@ -105,10 +103,7 @@ if (isset($_GET["firebird"])) {
function connect($credentials) {
$connection = new Db;
if ($connection->connect($credentials[0], $credentials[1], $credentials[2])) {
return $connection;
}
return $connection->error;
return ($connection->attach($credentials[0], $credentials[1], $credentials[2]) ?: $connection);
}
function get_databases($flush) {