Connection.php
2 years ago
DebugStack.php
2 years ago
Driver.php
2 years ago
LoggerChain.php
2 years ago
Middleware.php
2 years ago
SQLLogger.php
2 years ago
Statement.php
2 years ago
index.php
2 years ago
Statement.php
51 lines
| 1 | <?php |
| 2 | declare (strict_types=1); |
| 3 | namespace MailPoetVendor\Doctrine\DBAL\Logging; |
| 4 | if (!defined('ABSPATH')) exit; |
| 5 | use MailPoetVendor\Doctrine\DBAL\Driver\Middleware\AbstractStatementMiddleware; |
| 6 | use MailPoetVendor\Doctrine\DBAL\Driver\Result as ResultInterface; |
| 7 | use MailPoetVendor\Doctrine\DBAL\Driver\Statement as StatementInterface; |
| 8 | use MailPoetVendor\Doctrine\DBAL\ParameterType; |
| 9 | use MailPoetVendor\Doctrine\Deprecations\Deprecation; |
| 10 | use MailPoetVendor\Psr\Log\LoggerInterface; |
| 11 | use function array_slice; |
| 12 | use function func_get_args; |
| 13 | use function func_num_args; |
| 14 | final class Statement extends AbstractStatementMiddleware |
| 15 | { |
| 16 | private LoggerInterface $logger; |
| 17 | private string $sql; |
| 18 | private array $params = []; |
| 19 | private array $types = []; |
| 20 | public function __construct(StatementInterface $statement, LoggerInterface $logger, string $sql) |
| 21 | { |
| 22 | parent::__construct($statement); |
| 23 | $this->logger = $logger; |
| 24 | $this->sql = $sql; |
| 25 | } |
| 26 | public function bindParam($param, &$variable, $type = ParameterType::STRING, $length = null) |
| 27 | { |
| 28 | Deprecation::trigger('doctrine/dbal', 'https://github.com/doctrine/dbal/pull/5563', '%s is deprecated. Use bindValue() instead.', __METHOD__); |
| 29 | if (func_num_args() < 3) { |
| 30 | Deprecation::trigger('doctrine/dbal', 'https://github.com/doctrine/dbal/pull/5558', 'Not passing $type to Statement::bindParam() is deprecated.' . ' Pass the type corresponding to the parameter being bound.'); |
| 31 | } |
| 32 | $this->params[$param] =& $variable; |
| 33 | $this->types[$param] = $type; |
| 34 | return parent::bindParam($param, $variable, $type, ...array_slice(func_get_args(), 3)); |
| 35 | } |
| 36 | public function bindValue($param, $value, $type = ParameterType::STRING) |
| 37 | { |
| 38 | if (func_num_args() < 3) { |
| 39 | Deprecation::trigger('doctrine/dbal', 'https://github.com/doctrine/dbal/pull/5558', 'Not passing $type to Statement::bindValue() is deprecated.' . ' Pass the type corresponding to the parameter being bound.'); |
| 40 | } |
| 41 | $this->params[$param] = $value; |
| 42 | $this->types[$param] = $type; |
| 43 | return parent::bindValue($param, $value, $type); |
| 44 | } |
| 45 | public function execute($params = null) : ResultInterface |
| 46 | { |
| 47 | $this->logger->debug('Executing statement: {sql} (parameters: {params}, types: {types})', ['sql' => $this->sql, 'params' => $params ?? $this->params, 'types' => $this->types]); |
| 48 | return parent::execute($params); |
| 49 | } |
| 50 | } |
| 51 |