‪TYPO3CMS  ‪main
LoggingStatement.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\Result as ResultInterface;
21 use Doctrine\DBAL\Driver\Statement;
22 use Doctrine\DBAL\Driver\Statement as StatementInterface;
23 use Doctrine\DBAL\ParameterType;
24 
30 final class ‪LoggingStatement implements Statement
31 {
32  private array ‪$params = [];
33  private array ‪$types = [];
34 
35  public function ‪__construct(
36  private StatementInterface $wrappedStatement,
37  private ‪DoctrineSqlLogger $logger,
38  private string $sql
39  ) {}
40 
41  public function ‪bindValue(int|string $param, mixed $value, ParameterType $type = ParameterType::STRING): void
42  {
43  $this->params[$param] = $value;
44  $this->types[$param] = $type;
45 
46  $this->wrappedStatement->bindValue($param, $value, $type);
47  }
48 
49  public function ‪execute(): ResultInterface
50  {
51  $this->logger->startQuery($this->sql, $this->params, $this->types);
52  $result = $this->wrappedStatement->execute();
53  $this->logger->stopQuery();
54 
55  return $result;
56  }
57 }
‪TYPO3\CMS\Adminpanel\Log\LoggingStatement\$params
‪array $params
Definition: LoggingStatement.php:32
‪TYPO3\CMS\Adminpanel\Log
Definition: DoctrineSqlLogger.php:18
‪TYPO3\CMS\Adminpanel\Log\DoctrineSqlLogger
Definition: DoctrineSqlLogger.php:30
‪TYPO3\CMS\Adminpanel\Log\LoggingStatement\bindValue
‪bindValue(int|string $param, mixed $value, ParameterType $type=ParameterType::STRING)
Definition: LoggingStatement.php:41
‪TYPO3\CMS\Adminpanel\Log\LoggingStatement
Definition: LoggingStatement.php:31
‪TYPO3\CMS\Adminpanel\Log\LoggingStatement\execute
‪execute()
Definition: LoggingStatement.php:49
‪TYPO3\CMS\Adminpanel\Log\LoggingStatement\$types
‪array $types
Definition: LoggingStatement.php:33
‪TYPO3\CMS\Adminpanel\Log\LoggingStatement\__construct
‪__construct(private StatementInterface $wrappedStatement, private DoctrineSqlLogger $logger, private string $sql)
Definition: LoggingStatement.php:35