Skip to content

Commit 53c74cb

Browse files
committed
Merge branch 'main' of github.com:utopia-php/database into joins9
2 parents 842997e + 72ee161 commit 53c74cb

4 files changed

Lines changed: 30 additions & 1 deletion

File tree

src/Database/Adapter.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,4 +1583,9 @@ abstract public function getSupportForTransactionRetries(): bool;
15831583
* @return bool
15841584
*/
15851585
abstract public function getSupportForNestedTransactions(): bool;
1586+
1587+
/**
1588+
* @return mixed
1589+
*/
1590+
abstract public function getDriver(): mixed;
15861591
}

src/Database/Adapter/Mongo.php

Lines changed: 10 additions & 1 deletion
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()) {
@@ -2969,7 +2978,7 @@ protected function getQueryValue(string $method, mixed $value): mixed
29692978
*/
29702979
protected function getOrder(string $order): int
29712980
{
2972-
return match ($order) {
2981+
return match (\strtoupper($order)) {
29732982
Database::ORDER_ASC => 1,
29742983
Database::ORDER_DESC => -1,
29752984
default => throw new DatabaseException('Unknown sort order:' . $order . '. Must be one of ' . Database::ORDER_ASC . ', ' . Database::ORDER_DESC),

src/Database/Adapter/Pool.php

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

74+
public function getDriver(): mixed
75+
{
76+
return $this->delegate(__FUNCTION__, \func_get_args());
77+
}
78+
7479
public function before(string $event, string $name = '', ?callable $callback = null): static
7580
{
7681
$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
@@ -2190,12 +2190,22 @@ protected function applyOperatorToValue(Operator $operator, mixed $value): mixed
21902190
/**
21912191
* Returns the current PDO object
21922192
* @return mixed
2193+
* @deprecated Use getDriver() instead
21932194
*/
21942195
protected function getPDO(): mixed
21952196
{
21962197
return $this->pdo;
21972198
}
21982199

2200+
/**
2201+
* Returns the current PDO object
2202+
* @return mixed
2203+
*/
2204+
public function getDriver(): mixed
2205+
{
2206+
return $this->pdo;
2207+
}
2208+
21992209
/**
22002210
* Get PDO Type
22012211
*

0 commit comments

Comments
 (0)