diff options
Diffstat (limited to 'vendor/doctrine/dbal/src/Logging/Connection.php')
-rw-r--r-- | vendor/doctrine/dbal/src/Logging/Connection.php | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/vendor/doctrine/dbal/src/Logging/Connection.php b/vendor/doctrine/dbal/src/Logging/Connection.php new file mode 100644 index 0000000..9c220de --- /dev/null +++ b/vendor/doctrine/dbal/src/Logging/Connection.php | |||
@@ -0,0 +1,69 @@ | |||
1 | <?php | ||
2 | |||
3 | declare(strict_types=1); | ||
4 | |||
5 | namespace Doctrine\DBAL\Logging; | ||
6 | |||
7 | use Doctrine\DBAL\Driver\Connection as ConnectionInterface; | ||
8 | use Doctrine\DBAL\Driver\Middleware\AbstractConnectionMiddleware; | ||
9 | use Doctrine\DBAL\Driver\Result; | ||
10 | use Doctrine\DBAL\Driver\Statement as DriverStatement; | ||
11 | use Psr\Log\LoggerInterface; | ||
12 | |||
13 | final class Connection extends AbstractConnectionMiddleware | ||
14 | { | ||
15 | /** @internal This connection can be only instantiated by its driver. */ | ||
16 | public function __construct(ConnectionInterface $connection, private readonly LoggerInterface $logger) | ||
17 | { | ||
18 | parent::__construct($connection); | ||
19 | } | ||
20 | |||
21 | public function __destruct() | ||
22 | { | ||
23 | $this->logger->info('Disconnecting'); | ||
24 | } | ||
25 | |||
26 | public function prepare(string $sql): DriverStatement | ||
27 | { | ||
28 | return new Statement( | ||
29 | parent::prepare($sql), | ||
30 | $this->logger, | ||
31 | $sql, | ||
32 | ); | ||
33 | } | ||
34 | |||
35 | public function query(string $sql): Result | ||
36 | { | ||
37 | $this->logger->debug('Executing query: {sql}', ['sql' => $sql]); | ||
38 | |||
39 | return parent::query($sql); | ||
40 | } | ||
41 | |||
42 | public function exec(string $sql): int|string | ||
43 | { | ||
44 | $this->logger->debug('Executing statement: {sql}', ['sql' => $sql]); | ||
45 | |||
46 | return parent::exec($sql); | ||
47 | } | ||
48 | |||
49 | public function beginTransaction(): void | ||
50 | { | ||
51 | $this->logger->debug('Beginning transaction'); | ||
52 | |||
53 | parent::beginTransaction(); | ||
54 | } | ||
55 | |||
56 | public function commit(): void | ||
57 | { | ||
58 | $this->logger->debug('Committing transaction'); | ||
59 | |||
60 | parent::commit(); | ||
61 | } | ||
62 | |||
63 | public function rollBack(): void | ||
64 | { | ||
65 | $this->logger->debug('Rolling back transaction'); | ||
66 | |||
67 | parent::rollBack(); | ||
68 | } | ||
69 | } | ||