-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
520 additions
and
263 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<?php | ||
|
||
namespace Doctrine\DBAL\Driver\Middleware; | ||
|
||
use Doctrine\DBAL\Driver\Connection; | ||
use Doctrine\DBAL\Driver\Result; | ||
use Doctrine\DBAL\Driver\ServerInfoAwareConnection; | ||
use Doctrine\DBAL\Driver\Statement; | ||
use Doctrine\DBAL\ParameterType; | ||
use Doctrine\Deprecations\Deprecation; | ||
use LogicException; | ||
|
||
abstract class AbstractConnectionMiddleware implements ServerInfoAwareConnection | ||
{ | ||
/** @var Connection */ | ||
private $wrappedConnection; | ||
|
||
public function __construct(Connection $wrappedConnection) | ||
{ | ||
$this->wrappedConnection = $wrappedConnection; | ||
} | ||
|
||
public function prepare(string $sql): Statement | ||
{ | ||
return $this->wrappedConnection->prepare($sql); | ||
} | ||
|
||
public function query(string $sql): Result | ||
{ | ||
return $this->wrappedConnection->query($sql); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function quote($value, $type = ParameterType::STRING) | ||
{ | ||
return $this->wrappedConnection->quote($value, $type); | ||
} | ||
|
||
public function exec(string $sql): int | ||
{ | ||
return $this->wrappedConnection->exec($sql); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function lastInsertId($name = null) | ||
{ | ||
if ($name !== null) { | ||
Deprecation::triggerIfCalledFromOutside( | ||
'doctrine/dbal', | ||
'https://github.com/doctrine/dbal/issues/4687', | ||
'The usage of Connection::lastInsertId() with a sequence name is deprecated.' | ||
); | ||
} | ||
|
||
return $this->wrappedConnection->lastInsertId($name); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function beginTransaction() | ||
{ | ||
return $this->wrappedConnection->beginTransaction(); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function commit() | ||
{ | ||
return $this->wrappedConnection->commit(); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function rollBack() | ||
{ | ||
return $this->wrappedConnection->rollBack(); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getServerVersion() | ||
{ | ||
if (! $this->wrappedConnection instanceof ServerInfoAwareConnection) { | ||
throw new LogicException('The underlying connection is not a ServerInfoAwareConnection'); | ||
} | ||
|
||
return $this->wrappedConnection->getServerVersion(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
namespace Doctrine\DBAL\Driver\Middleware; | ||
|
||
use Doctrine\DBAL\Connection; | ||
use Doctrine\DBAL\Driver; | ||
use Doctrine\DBAL\Driver\API\ExceptionConverter; | ||
use Doctrine\DBAL\Platforms\AbstractPlatform; | ||
use Doctrine\DBAL\VersionAwarePlatformDriver; | ||
|
||
abstract class AbstractDriverMiddleware implements VersionAwarePlatformDriver | ||
{ | ||
/** @var Driver */ | ||
private $wrappedDriver; | ||
|
||
public function __construct(Driver $wrappedDriver) | ||
{ | ||
$this->wrappedDriver = $wrappedDriver; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function connect(array $params) | ||
{ | ||
return $this->wrappedDriver->connect($params); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getDatabasePlatform() | ||
{ | ||
return $this->wrappedDriver->getDatabasePlatform(); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getSchemaManager(Connection $conn, AbstractPlatform $platform) | ||
{ | ||
return $this->wrappedDriver->getSchemaManager($conn, $platform); | ||
} | ||
|
||
public function getExceptionConverter(): ExceptionConverter | ||
{ | ||
return $this->wrappedDriver->getExceptionConverter(); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function createDatabasePlatformForVersion($version) | ||
{ | ||
if ($this->wrappedDriver instanceof VersionAwarePlatformDriver) { | ||
return $this->wrappedDriver->createDatabasePlatformForVersion($version); | ||
} | ||
|
||
return $this->wrappedDriver->getDatabasePlatform(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?php | ||
|
||
namespace Doctrine\DBAL\Driver\Middleware; | ||
|
||
use Doctrine\DBAL\Driver\Result; | ||
|
||
abstract class AbstractResultMiddleware implements Result | ||
{ | ||
/** @var Result */ | ||
private $wrappedResult; | ||
|
||
public function __construct(Result $result) | ||
{ | ||
$this->wrappedResult = $result; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function fetchNumeric() | ||
{ | ||
return $this->wrappedResult->fetchNumeric(); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function fetchAssociative() | ||
{ | ||
return $this->wrappedResult->fetchAssociative(); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function fetchOne() | ||
{ | ||
return $this->wrappedResult->fetchOne(); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function fetchAllNumeric(): array | ||
{ | ||
return $this->wrappedResult->fetchAllNumeric(); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function fetchAllAssociative(): array | ||
{ | ||
return $this->wrappedResult->fetchAllAssociative(); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function fetchFirstColumn(): array | ||
{ | ||
return $this->wrappedResult->fetchFirstColumn(); | ||
} | ||
|
||
public function rowCount(): int | ||
{ | ||
return $this->wrappedResult->rowCount(); | ||
} | ||
|
||
public function columnCount(): int | ||
{ | ||
return $this->wrappedResult->columnCount(); | ||
} | ||
|
||
public function free(): void | ||
{ | ||
$this->wrappedResult->free(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
namespace Doctrine\DBAL\Driver\Middleware; | ||
|
||
use Doctrine\DBAL\Driver\Result; | ||
use Doctrine\DBAL\Driver\Statement; | ||
use Doctrine\DBAL\ParameterType; | ||
|
||
abstract class AbstractStatementMiddleware implements Statement | ||
{ | ||
/** @var Statement */ | ||
private $wrappedStatement; | ||
|
||
public function __construct(Statement $wrappedStatement) | ||
{ | ||
$this->wrappedStatement = $wrappedStatement; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function bindValue($param, $value, $type = ParameterType::STRING) | ||
{ | ||
return $this->wrappedStatement->bindValue($param, $value, $type); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function bindParam($param, &$variable, $type = ParameterType::STRING, $length = null) | ||
{ | ||
return $this->wrappedStatement->bindParam($param, $variable, $type, $length); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function execute($params = null): Result | ||
{ | ||
return $this->wrappedStatement->execute($params); | ||
} | ||
} |
Oops, something went wrong.