Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bin/tasks/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Utopia\Database\Adapter\Mongo;
use Utopia\Database\Adapter\MySQL;
use Utopia\Database\Database;
use Utopia\Database\PDO;
use Utopia\Mongo\Client;
use Utopia\Validator\Text;

Expand Down
1 change: 1 addition & 0 deletions bin/tasks/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use Utopia\Database\Document;
use Utopia\Database\Helpers\Permission;
use Utopia\Database\Helpers\Role;
use Utopia\Database\PDO;
use Utopia\Database\Validator\Authorization;
use Utopia\Mongo\Client;
use Utopia\Validator\Numeric;
Expand Down
22 changes: 11 additions & 11 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 58 additions & 0 deletions src/Database/PDO.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

namespace Utopia\Database;

/**
* A PDO wrapper that forwards method calls to the internal PDO instance.
*
* @mixin \PDO
*/
class PDO
{
protected \PDO $pdo;

/**
* @param string $dsn
* @param ?string $username
* @param ?string $password
* @param array<mixed> $config
*/
public function __construct(
protected string $dsn,
protected ?string $username,
protected ?string $password,
protected array $config = []
) {
$this->pdo = new \PDO(
$this->dsn,
$this->username,
$this->password,
$this->config
);
}

/**
* @param string $method
* @param array<mixed> $args
* @return mixed
*/
public function __call(string $method, array $args): mixed
{
return $this->pdo->{$method}(...$args);
}

/**
* Create a new connection to the database
*
* @return void
*/
public function reconnect(): void
{
$this->pdo = new \PDO(
$this->dsn,
$this->username,
$this->password,
$this->config
);
}
}
2 changes: 1 addition & 1 deletion tests/e2e/Adapter/MariaDBTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

namespace Tests\E2E\Adapter;

use PDO;
use Redis;
use Utopia\Cache\Adapter\Redis as RedisAdapter;
use Utopia\Cache\Cache;
use Utopia\Database\Adapter\MariaDB;
use Utopia\Database\Database;
use Utopia\Database\PDO;

class MariaDBTest extends Base
{
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/Adapter/MirrorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Tests\E2E\Adapter;

use PDO;
use Redis;
use Utopia\Cache\Adapter\Redis as RedisAdapter;
use Utopia\Cache\Cache;
Expand All @@ -18,6 +17,7 @@
use Utopia\Database\Helpers\Permission;
use Utopia\Database\Helpers\Role;
use Utopia\Database\Mirror;
use Utopia\Database\PDO;

class MirrorTest extends Base
{
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/Adapter/MySQLTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

namespace Tests\E2E\Adapter;

use PDO;
use Redis;
use Utopia\Cache\Adapter\Redis as RedisAdapter;
use Utopia\Cache\Cache;
use Utopia\Database\Adapter\MySQL;
use Utopia\Database\Database;
use Utopia\Database\PDO;

class MySQLTest extends Base
{
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/Adapter/PostgresTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

namespace Tests\E2E\Adapter;

use PDO;
use Redis;
use Utopia\Cache\Adapter\Redis as RedisAdapter;
use Utopia\Cache\Cache;
use Utopia\Database\Adapter\Postgres;
use Utopia\Database\Database;
use Utopia\Database\PDO;

class PostgresTest extends Base
{
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/Adapter/SQLiteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

namespace Tests\E2E\Adapter;

use PDO;
use Redis;
use Utopia\Cache\Adapter\Redis as RedisAdapter;
use Utopia\Cache\Cache;
use Utopia\Database\Adapter\SQLite;
use Utopia\Database\Database;
use Utopia\Database\PDO;

class SQLiteTest extends Base
{
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/Adapter/SharedTables/MariaDBTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

namespace Tests\E2E\Adapter\SharedTables;

use PDO;
use Redis;
use Tests\E2E\Adapter\Base;
use Utopia\Cache\Adapter\Redis as RedisAdapter;
use Utopia\Cache\Cache;
use Utopia\Database\Adapter\MariaDB;
use Utopia\Database\Database;
use Utopia\Database\PDO;

class MariaDBTest extends Base
{
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/Adapter/SharedTables/MySQLTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

namespace Tests\E2E\Adapter\SharedTables;

use PDO;
use Redis;
use Tests\E2E\Adapter\Base;
use Utopia\Cache\Adapter\Redis as RedisAdapter;
use Utopia\Cache\Cache;
use Utopia\Database\Adapter\MySQL;
use Utopia\Database\Database;
use Utopia\Database\PDO;

class MySQLTest extends Base
{
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/Adapter/SharedTables/PostgresTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

namespace Tests\E2E\Adapter\SharedTables;

use PDO;
use Redis;
use Tests\E2E\Adapter\Base;
use Utopia\Cache\Adapter\Redis as RedisAdapter;
use Utopia\Cache\Cache;
use Utopia\Database\Adapter\Postgres;
use Utopia\Database\Database;
use Utopia\Database\PDO;

class PostgresTest extends Base
{
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/Adapter/SharedTables/SQLiteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

namespace Tests\E2E\Adapter\SharedTables;

use PDO;
use Redis;
use Tests\E2E\Adapter\Base;
use Utopia\Cache\Adapter\Redis as RedisAdapter;
use Utopia\Cache\Cache;
use Utopia\Database\Adapter\SQLite;
use Utopia\Database\Database;
use Utopia\Database\PDO;

class SQLiteTest extends Base
{
Expand Down
Loading