diff options
| author | Lester Caine <lester@lsces.co.uk> | 2026-05-11 09:25:03 +0100 |
|---|---|---|
| committer | Lester Caine <lester@lsces.co.uk> | 2026-05-11 09:25:03 +0100 |
| commit | 4c5724df39a4f22d5b1b1117cc4a6200ce186784 (patch) | |
| tree | 431dad255d5cf0f48d4002f21d49c762579b1ee1 /app/DB.php | |
| parent | a64cc9967a255bf52811e8a74d2e30f88cb56671 (diff) | |
| download | webtrees-firebird.tar.gz webtrees-firebird.tar.bz2 webtrees-firebird.zip | |
Add Firebird/PDO support via lsces/illuminate-firebirdHEADv2.2.7-lscfirebird
Diffstat (limited to 'app/DB.php')
| -rw-r--r-- | app/DB.php | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/app/DB.php b/app/DB.php index f71ecd8d71..1e04911cee 100644 --- a/app/DB.php +++ b/app/DB.php @@ -20,6 +20,8 @@ declare(strict_types=1); namespace Fisharebest\Webtrees; use Closure; +use Illuminate\Container\Container; +use Illuminate\Database\Connection; use Illuminate\Database\Capsule\Manager; use Illuminate\Database\Query\Builder; use Illuminate\Database\Query\Expression; @@ -27,6 +29,8 @@ use PDO; use PDOException; use RuntimeException; use SensitiveParameter; +use Firebird\Illuminate\FirebirdConnection; +use Firebird\Illuminate\FirebirdConnector; final class DB extends Manager { @@ -119,8 +123,19 @@ final class DB extends Manager $database = Webtrees::ROOT_DIR . 'data/' . $database . '.sqlite'; } - $capsule = new self(); - $capsule->addConnection([ + $container = new Container(); + $capsule = new self($container); + + if ($driver === self::FIREBIRD) { + Connection::resolverFor('firebird', + function ($connection, $database, $tablePrefix, $config) + { + return new FirebirdConnection($connection, $database, $tablePrefix, $config); + }); + $container->instance('db.connector.firebird', new FirebirdConnector); + } + + $capsule->addConnection([ 'driver' => $driver, 'host' => $host, 'port' => $port, @@ -160,7 +175,14 @@ final class DB extends Manager public static function lastInsertId(): int { - $return = self::pdo()->lastInsertId(); + if (self::driverName() != self::FIREBIRD) { + $return = self::pdo()->lastInsertId(); + } else { + // Get the connection instance and access its lastInsertId property + $connection = self::connection(); // Get the connection instance + $return = $connection->getLastInsertId(); + } + if ($return === false) { throw new RuntimeException('Unable to retrieve last insert ID'); |
