forked from doctrine/dbal
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 3.3.x: Deprecate Connection::getWrappedConnection(), mark Connection::connect() internal Add Connection::getNativeConnection() Provide abstract middleware classes
- Loading branch information
Showing
31 changed files
with
703 additions
and
199 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
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
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
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
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
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
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,87 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\DBAL\Driver\Middleware; | ||
|
||
use Doctrine\DBAL\Driver\Connection; | ||
use Doctrine\DBAL\Driver\Result; | ||
use Doctrine\DBAL\Driver\Statement; | ||
use LogicException; | ||
|
||
use function get_class; | ||
use function method_exists; | ||
use function sprintf; | ||
|
||
abstract class AbstractConnectionMiddleware implements Connection | ||
{ | ||
private Connection $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); | ||
} | ||
|
||
public function quote(string $value): string | ||
{ | ||
return $this->wrappedConnection->quote($value); | ||
} | ||
|
||
public function exec(string $sql): int | ||
{ | ||
return $this->wrappedConnection->exec($sql); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function lastInsertId() | ||
{ | ||
return $this->wrappedConnection->lastInsertId(); | ||
} | ||
|
||
public function beginTransaction(): void | ||
{ | ||
$this->wrappedConnection->beginTransaction(); | ||
} | ||
|
||
public function commit(): void | ||
{ | ||
$this->wrappedConnection->commit(); | ||
} | ||
|
||
public function rollBack(): void | ||
{ | ||
$this->wrappedConnection->rollBack(); | ||
} | ||
|
||
public function getServerVersion(): string | ||
{ | ||
return $this->wrappedConnection->getServerVersion(); | ||
} | ||
|
||
/** | ||
* @return resource|object | ||
*/ | ||
public function getNativeConnection() | ||
{ | ||
if (! method_exists($this->wrappedConnection, 'getNativeConnection')) { | ||
throw new LogicException(sprintf( | ||
'The driver connection %s does not support accessing the native connection.', | ||
get_class($this->wrappedConnection) | ||
)); | ||
} | ||
|
||
return $this->wrappedConnection->getNativeConnection(); | ||
} | ||
} |
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,46 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\DBAL\Driver\Middleware; | ||
|
||
use Doctrine\DBAL\Connection; | ||
use Doctrine\DBAL\Driver; | ||
use Doctrine\DBAL\Driver\API\ExceptionConverter; | ||
use Doctrine\DBAL\Driver\Connection as DriverConnection; | ||
use Doctrine\DBAL\Platforms\AbstractPlatform; | ||
use Doctrine\DBAL\Schema\AbstractSchemaManager; | ||
use Doctrine\DBAL\ServerVersionProvider; | ||
|
||
abstract class AbstractDriverMiddleware implements Driver | ||
{ | ||
private Driver $wrappedDriver; | ||
|
||
public function __construct(Driver $wrappedDriver) | ||
{ | ||
$this->wrappedDriver = $wrappedDriver; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function connect(array $params): DriverConnection | ||
{ | ||
return $this->wrappedDriver->connect($params); | ||
} | ||
|
||
public function getDatabasePlatform(ServerVersionProvider $versionProvider): AbstractPlatform | ||
{ | ||
return $this->wrappedDriver->getDatabasePlatform($versionProvider); | ||
} | ||
|
||
public function getSchemaManager(Connection $conn, AbstractPlatform $platform): AbstractSchemaManager | ||
{ | ||
return $this->wrappedDriver->getSchemaManager($conn, $platform); | ||
} | ||
|
||
public function getExceptionConverter(): ExceptionConverter | ||
{ | ||
return $this->wrappedDriver->getExceptionConverter(); | ||
} | ||
} |
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,80 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\DBAL\Driver\Middleware; | ||
|
||
use Doctrine\DBAL\Driver\Result; | ||
|
||
abstract class AbstractResultMiddleware implements Result | ||
{ | ||
private Result $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(); | ||
} | ||
} |
Oops, something went wrong.