Skip to content

Commit 72ee161

Browse files
authored
Merge pull request #849 from utopia-php/pool-adapter-get-driver
2 parents 0b1b4b4 + 9f8b220 commit 72ee161

File tree

4 files changed

+29
-0
lines changed

4 files changed

+29
-0
lines changed

src/Database/Adapter.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1581,4 +1581,9 @@ abstract public function getSupportForTransactionRetries(): bool;
15811581
* @return bool
15821582
*/
15831583
abstract public function getSupportForNestedTransactions(): bool;
1584+
1585+
/**
1586+
* @return mixed
1587+
*/
1588+
abstract public function getDriver(): mixed;
15841589
}

src/Database/Adapter/Mongo.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,15 @@ public function __construct(Client $client)
7777
$this->client->connect();
7878
}
7979

80+
/**
81+
* Returns the current Mongo client
82+
* @return mixed
83+
*/
84+
public function getDriver(): mixed
85+
{
86+
return $this->client;
87+
}
88+
8089
public function setTimeout(int $milliseconds, string $event = Database::EVENT_ALL): void
8190
{
8291
if (!$this->getSupportForTimeouts()) {

src/Database/Adapter/Pool.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ public function delegate(string $method, array $args): mixed
7070
});
7171
}
7272

73+
public function getDriver(): mixed
74+
{
75+
return $this->delegate(__FUNCTION__, \func_get_args());
76+
}
77+
7378
public function before(string $event, string $name = '', ?callable $callback = null): static
7479
{
7580
$this->delegate(__FUNCTION__, \func_get_args());

src/Database/Adapter/SQL.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2179,12 +2179,22 @@ protected function applyOperatorToValue(Operator $operator, mixed $value): mixed
21792179
/**
21802180
* Returns the current PDO object
21812181
* @return mixed
2182+
* @deprecated Use getDriver() instead
21822183
*/
21832184
protected function getPDO(): mixed
21842185
{
21852186
return $this->pdo;
21862187
}
21872188

2189+
/**
2190+
* Returns the current PDO object
2191+
* @return mixed
2192+
*/
2193+
public function getDriver(): mixed
2194+
{
2195+
return $this->pdo;
2196+
}
2197+
21882198
/**
21892199
* Get PDO Type
21902200
*

0 commit comments

Comments
 (0)