‪TYPO3CMS  ‪main
LoggingConnection.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use Doctrine\DBAL\Driver\Connection as ConnectionInterface;
21 use Doctrine\DBAL\Driver\Middleware\AbstractConnectionMiddleware;
22 use Doctrine\DBAL\Driver\Result;
23 use Doctrine\DBAL\Driver\Statement as DriverStatement;
24 
30 final class ‪LoggingConnection extends AbstractConnectionMiddleware
31 {
33 
34  public function ‪__construct(ConnectionInterface $connection, ‪DoctrineSqlLogger ‪$logger)
35  {
36  parent::__construct($connection);
37 
38  $this->logger = ‪$logger;
39  }
40 
41  public function ‪prepare(string $sql): DriverStatement
42  {
43  return new ‪LoggingStatement(parent::prepare($sql), $this->logger, $sql);
44  }
45 
46  public function ‪query(string $sql): Result
47  {
48  $this->logger->startQuery($sql);
49  $query = parent::query($sql);
50  $this->logger->stopQuery();
51 
52  return $query;
53  }
54 
55  public function ‪exec(string $sql): int
56  {
57  $this->logger->startQuery($sql);
58  $query = parent::exec($sql);
59  $this->logger->stopQuery();
60 
61  return $query;
62  }
63 }
‪TYPO3\CMS\Adminpanel\Log\LoggingConnection
Definition: LoggingConnection.php:31
‪TYPO3\CMS\Adminpanel\Log
Definition: DoctrineSqlLogger.php:18
‪TYPO3\CMS\Adminpanel\Log\DoctrineSqlLogger
Definition: DoctrineSqlLogger.php:30
‪TYPO3\CMS\Adminpanel\Log\LoggingConnection\__construct
‪__construct(ConnectionInterface $connection, DoctrineSqlLogger $logger)
Definition: LoggingConnection.php:34
‪TYPO3\CMS\Adminpanel\Log\LoggingStatement
Definition: LoggingStatement.php:31
‪TYPO3\CMS\Adminpanel\Log\LoggingConnection\$logger
‪DoctrineSqlLogger $logger
Definition: LoggingConnection.php:32
‪TYPO3\CMS\Adminpanel\Log\LoggingConnection\prepare
‪prepare(string $sql)
Definition: LoggingConnection.php:41
‪TYPO3\CMS\Adminpanel\Log\LoggingConnection\exec
‪exec(string $sql)
Definition: LoggingConnection.php:55
‪TYPO3\CMS\Adminpanel\Log\LoggingConnection\query
‪query(string $sql)
Definition: LoggingConnection.php:46