ArrayParameters
2 years ago
Cache
9 months ago
Driver
9 months ago
Event
2 years ago
Exception
9 months ago
Id
2 years ago
Logging
2 years ago
Platforms
9 months ago
Portability
2 years ago
Query
2 years ago
SQL
9 months ago
Schema
8 months ago
Types
9 months ago
ArrayParameterType.php
2 years ago
ColumnCase.php
2 years ago
Configuration.php
9 months ago
Connection.php
9 months ago
ConnectionException.php
2 years ago
Driver.php
2 years ago
DriverManager.php
2 years ago
Events.php
2 years ago
Exception.php
2 years ago
ExpandArrayParameters.php
2 years ago
FetchMode.php
2 years ago
LockMode.php
2 years ago
ParameterType.php
2 years ago
Query.php
2 years ago
Result.php
2 years ago
Statement.php
2 years ago
TransactionIsolationLevel.php
2 years ago
VersionAwarePlatformDriver.php
2 years ago
index.php
2 years ago
Statement.php
106 lines
| 1 | <?php |
| 2 | namespace MailPoetVendor\Doctrine\DBAL; |
| 3 | if (!defined('ABSPATH')) exit; |
| 4 | use MailPoetVendor\Doctrine\DBAL\Platforms\AbstractPlatform; |
| 5 | use MailPoetVendor\Doctrine\DBAL\Types\Type; |
| 6 | use MailPoetVendor\Doctrine\Deprecations\Deprecation; |
| 7 | use function func_num_args; |
| 8 | use function is_string; |
| 9 | class Statement |
| 10 | { |
| 11 | protected $sql; |
| 12 | protected $params = []; |
| 13 | protected $types = []; |
| 14 | protected $stmt; |
| 15 | protected $platform; |
| 16 | protected $conn; |
| 17 | public function __construct(Connection $conn, Driver\Statement $statement, string $sql) |
| 18 | { |
| 19 | $this->conn = $conn; |
| 20 | $this->stmt = $statement; |
| 21 | $this->sql = $sql; |
| 22 | $this->platform = $conn->getDatabasePlatform(); |
| 23 | } |
| 24 | public function bindValue($param, $value, $type = ParameterType::STRING) |
| 25 | { |
| 26 | $this->params[$param] = $value; |
| 27 | $this->types[$param] = $type; |
| 28 | $bindingType = ParameterType::STRING; |
| 29 | if ($type !== null) { |
| 30 | if (is_string($type)) { |
| 31 | $type = Type::getType($type); |
| 32 | } |
| 33 | $bindingType = $type; |
| 34 | if ($type instanceof Type) { |
| 35 | $value = $type->convertToDatabaseValue($value, $this->platform); |
| 36 | $bindingType = $type->getBindingType(); |
| 37 | } |
| 38 | } |
| 39 | try { |
| 40 | return $this->stmt->bindValue($param, $value, $bindingType); |
| 41 | } catch (Driver\Exception $e) { |
| 42 | throw $this->conn->convertException($e); |
| 43 | } |
| 44 | } |
| 45 | public function bindParam($param, &$variable, $type = ParameterType::STRING, $length = null) |
| 46 | { |
| 47 | Deprecation::trigger('doctrine/dbal', 'https://github.com/doctrine/dbal/pull/5563', '%s is deprecated. Use bindValue() instead.', __METHOD__); |
| 48 | $this->params[$param] = $variable; |
| 49 | $this->types[$param] = $type; |
| 50 | try { |
| 51 | if (func_num_args() > 3) { |
| 52 | return $this->stmt->bindParam($param, $variable, $type, $length); |
| 53 | } |
| 54 | return $this->stmt->bindParam($param, $variable, $type); |
| 55 | } catch (Driver\Exception $e) { |
| 56 | throw $this->conn->convertException($e); |
| 57 | } |
| 58 | } |
| 59 | public function execute($params = null) : Result |
| 60 | { |
| 61 | Deprecation::triggerIfCalledFromOutside('doctrine/dbal', 'https://github.com/doctrine/dbal/pull/4580', '%s() is deprecated, use Statement::executeQuery() or Statement::executeStatement() instead', __METHOD__); |
| 62 | if ($params !== null) { |
| 63 | $this->params = $params; |
| 64 | } |
| 65 | $logger = $this->conn->getConfiguration()->getSQLLogger(); |
| 66 | if ($logger !== null) { |
| 67 | $logger->startQuery($this->sql, $this->params, $this->types); |
| 68 | } |
| 69 | try { |
| 70 | return new Result($this->stmt->execute($params), $this->conn); |
| 71 | } catch (Driver\Exception $ex) { |
| 72 | throw $this->conn->convertExceptionDuringQuery($ex, $this->sql, $this->params, $this->types); |
| 73 | } finally { |
| 74 | if ($logger !== null) { |
| 75 | $logger->stopQuery(); |
| 76 | } |
| 77 | } |
| 78 | } |
| 79 | public function executeQuery(array $params = []) : Result |
| 80 | { |
| 81 | if (func_num_args() > 0) { |
| 82 | Deprecation::trigger('doctrine/dbal', 'https://github.com/doctrine/dbal/pull/5556', 'Passing $params to Statement::executeQuery() is deprecated. Bind parameters using' . ' Statement::bindParam() or Statement::bindValue() instead.'); |
| 83 | } |
| 84 | if ($params === []) { |
| 85 | $params = null; |
| 86 | // Workaround as long execute() exists and used internally. |
| 87 | } |
| 88 | return $this->execute($params); |
| 89 | } |
| 90 | public function executeStatement(array $params = []) : int |
| 91 | { |
| 92 | if (func_num_args() > 0) { |
| 93 | Deprecation::trigger('doctrine/dbal', 'https://github.com/doctrine/dbal/pull/5556', 'Passing $params to Statement::executeStatement() is deprecated. Bind parameters using' . ' Statement::bindParam() or Statement::bindValue() instead.'); |
| 94 | } |
| 95 | if ($params === []) { |
| 96 | $params = null; |
| 97 | // Workaround as long execute() exists and used internally. |
| 98 | } |
| 99 | return $this->execute($params)->rowCount(); |
| 100 | } |
| 101 | public function getWrappedStatement() |
| 102 | { |
| 103 | return $this->stmt; |
| 104 | } |
| 105 | } |
| 106 |