mailpoet
/
vendor-prefixed
/
doctrine
/
dbal
/
src
/
Driver
/
Middleware
/
AbstractConnectionMiddleware.php
AbstractConnectionMiddleware.php
2 years ago
AbstractDriverMiddleware.php
2 years ago
AbstractResultMiddleware.php
2 years ago
AbstractStatementMiddleware.php
2 years ago
index.php
2 years ago
AbstractConnectionMiddleware.php
71 lines
| 1 | <?php |
| 2 | namespace MailPoetVendor\Doctrine\DBAL\Driver\Middleware; |
| 3 | if (!defined('ABSPATH')) exit; |
| 4 | use MailPoetVendor\Doctrine\DBAL\Driver\Connection; |
| 5 | use MailPoetVendor\Doctrine\DBAL\Driver\Result; |
| 6 | use MailPoetVendor\Doctrine\DBAL\Driver\ServerInfoAwareConnection; |
| 7 | use MailPoetVendor\Doctrine\DBAL\Driver\Statement; |
| 8 | use MailPoetVendor\Doctrine\DBAL\ParameterType; |
| 9 | use MailPoetVendor\Doctrine\Deprecations\Deprecation; |
| 10 | use LogicException; |
| 11 | use function get_class; |
| 12 | use function method_exists; |
| 13 | use function sprintf; |
| 14 | abstract class AbstractConnectionMiddleware implements ServerInfoAwareConnection |
| 15 | { |
| 16 | private Connection $wrappedConnection; |
| 17 | public function __construct(Connection $wrappedConnection) |
| 18 | { |
| 19 | $this->wrappedConnection = $wrappedConnection; |
| 20 | } |
| 21 | public function prepare(string $sql) : Statement |
| 22 | { |
| 23 | return $this->wrappedConnection->prepare($sql); |
| 24 | } |
| 25 | public function query(string $sql) : Result |
| 26 | { |
| 27 | return $this->wrappedConnection->query($sql); |
| 28 | } |
| 29 | public function quote($value, $type = ParameterType::STRING) |
| 30 | { |
| 31 | return $this->wrappedConnection->quote($value, $type); |
| 32 | } |
| 33 | public function exec(string $sql) : int |
| 34 | { |
| 35 | return $this->wrappedConnection->exec($sql); |
| 36 | } |
| 37 | public function lastInsertId($name = null) |
| 38 | { |
| 39 | if ($name !== null) { |
| 40 | Deprecation::triggerIfCalledFromOutside('doctrine/dbal', 'https://github.com/doctrine/dbal/issues/4687', 'The usage of Connection::lastInsertId() with a sequence name is deprecated.'); |
| 41 | } |
| 42 | return $this->wrappedConnection->lastInsertId($name); |
| 43 | } |
| 44 | public function beginTransaction() |
| 45 | { |
| 46 | return $this->wrappedConnection->beginTransaction(); |
| 47 | } |
| 48 | public function commit() |
| 49 | { |
| 50 | return $this->wrappedConnection->commit(); |
| 51 | } |
| 52 | public function rollBack() |
| 53 | { |
| 54 | return $this->wrappedConnection->rollBack(); |
| 55 | } |
| 56 | public function getServerVersion() |
| 57 | { |
| 58 | if (!$this->wrappedConnection instanceof ServerInfoAwareConnection) { |
| 59 | throw new LogicException('The underlying connection is not a ServerInfoAwareConnection'); |
| 60 | } |
| 61 | return $this->wrappedConnection->getServerVersion(); |
| 62 | } |
| 63 | public function getNativeConnection() |
| 64 | { |
| 65 | if (!method_exists($this->wrappedConnection, 'getNativeConnection')) { |
| 66 | throw new LogicException(sprintf('The driver connection %s does not support accessing the native connection.', get_class($this->wrappedConnection))); |
| 67 | } |
| 68 | return $this->wrappedConnection->getNativeConnection(); |
| 69 | } |
| 70 | } |
| 71 |