From 3dde66867e159fde9409e5b5ef8368b12f1e59a6 Mon Sep 17 00:00:00 2001 From: fogelito Date: Tue, 31 Mar 2026 15:56:21 +0300 Subject: [PATCH 1/3] Abstract getDriver --- src/Database/Adapter.php | 5 +++++ src/Database/Adapter/Mongo.php | 9 +++++++++ src/Database/Adapter/Pool.php | 7 +++++++ src/Database/Adapter/SQL.php | 11 ++++++++++- 4 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/Database/Adapter.php b/src/Database/Adapter.php index a0c1c238a..1a679c9d6 100644 --- a/src/Database/Adapter.php +++ b/src/Database/Adapter.php @@ -1581,4 +1581,9 @@ abstract public function getSupportForTransactionRetries(): bool; * @return bool */ abstract public function getSupportForNestedTransactions(): bool; + + /** + * @return mixed + */ + abstract protected function getDriver(): mixed; } diff --git a/src/Database/Adapter/Mongo.php b/src/Database/Adapter/Mongo.php index b462d1c28..f91d3999f 100644 --- a/src/Database/Adapter/Mongo.php +++ b/src/Database/Adapter/Mongo.php @@ -77,6 +77,15 @@ public function __construct(Client $client) $this->client->connect(); } + /** + * Returns the current PDO object + * @return mixed + */ + protected function getDriver(): mixed + { + return $this->client; + } + public function setTimeout(int $milliseconds, string $event = Database::EVENT_ALL): void { if (!$this->getSupportForTimeouts()) { diff --git a/src/Database/Adapter/Pool.php b/src/Database/Adapter/Pool.php index e89be89ac..2ba57a3fb 100644 --- a/src/Database/Adapter/Pool.php +++ b/src/Database/Adapter/Pool.php @@ -70,6 +70,13 @@ public function delegate(string $method, array $args): mixed }); } + protected function getDriver(): mixed + { + $this->delegate(__FUNCTION__, \func_get_args()); + + return $this; + } + public function before(string $event, string $name = '', ?callable $callback = null): static { $this->delegate(__FUNCTION__, \func_get_args()); diff --git a/src/Database/Adapter/SQL.php b/src/Database/Adapter/SQL.php index 8f0bd2db2..5d27d9dda 100644 --- a/src/Database/Adapter/SQL.php +++ b/src/Database/Adapter/SQL.php @@ -2177,14 +2177,23 @@ protected function applyOperatorToValue(Operator $operator, mixed $value): mixed } /** - * Returns the current PDO object * @return mixed + * @deprecated Use getDriver() instead */ protected function getPDO(): mixed { return $this->pdo; } + /** + * Returns the current PDO object + * @return mixed + */ + protected function getDriver(): mixed + { + return $this->pdo; + } + /** * Get PDO Type * From 2d5a3783bec70a92b8ff652bde4c60bf1558746e Mon Sep 17 00:00:00 2001 From: fogelito Date: Tue, 31 Mar 2026 15:59:31 +0300 Subject: [PATCH 2/3] message --- src/Database/Adapter/SQL.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Database/Adapter/SQL.php b/src/Database/Adapter/SQL.php index 5d27d9dda..47b820ff0 100644 --- a/src/Database/Adapter/SQL.php +++ b/src/Database/Adapter/SQL.php @@ -2177,6 +2177,7 @@ protected function applyOperatorToValue(Operator $operator, mixed $value): mixed } /** + * Returns the current PDO object * @return mixed * @deprecated Use getDriver() instead */ From 9f8b220d7536478ad043cc7eecd3f4af8f90ee32 Mon Sep 17 00:00:00 2001 From: fogelito Date: Tue, 31 Mar 2026 18:16:18 +0300 Subject: [PATCH 3/3] Change to public --- src/Database/Adapter.php | 2 +- src/Database/Adapter/Mongo.php | 4 ++-- src/Database/Adapter/Pool.php | 6 ++---- src/Database/Adapter/SQL.php | 2 +- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/Database/Adapter.php b/src/Database/Adapter.php index 1a679c9d6..a7b385cce 100644 --- a/src/Database/Adapter.php +++ b/src/Database/Adapter.php @@ -1585,5 +1585,5 @@ abstract public function getSupportForNestedTransactions(): bool; /** * @return mixed */ - abstract protected function getDriver(): mixed; + abstract public function getDriver(): mixed; } diff --git a/src/Database/Adapter/Mongo.php b/src/Database/Adapter/Mongo.php index f91d3999f..7ddde43d3 100644 --- a/src/Database/Adapter/Mongo.php +++ b/src/Database/Adapter/Mongo.php @@ -78,10 +78,10 @@ public function __construct(Client $client) } /** - * Returns the current PDO object + * Returns the current Mongo client * @return mixed */ - protected function getDriver(): mixed + public function getDriver(): mixed { return $this->client; } diff --git a/src/Database/Adapter/Pool.php b/src/Database/Adapter/Pool.php index 2ba57a3fb..668753387 100644 --- a/src/Database/Adapter/Pool.php +++ b/src/Database/Adapter/Pool.php @@ -70,11 +70,9 @@ public function delegate(string $method, array $args): mixed }); } - protected function getDriver(): mixed + public function getDriver(): mixed { - $this->delegate(__FUNCTION__, \func_get_args()); - - return $this; + return $this->delegate(__FUNCTION__, \func_get_args()); } public function before(string $event, string $name = '', ?callable $callback = null): static diff --git a/src/Database/Adapter/SQL.php b/src/Database/Adapter/SQL.php index 47b820ff0..6864e6aee 100644 --- a/src/Database/Adapter/SQL.php +++ b/src/Database/Adapter/SQL.php @@ -2190,7 +2190,7 @@ protected function getPDO(): mixed * Returns the current PDO object * @return mixed */ - protected function getDriver(): mixed + public function getDriver(): mixed { return $this->pdo; }