|
5 | 5 | namespace PhpDb\Sqlite\Pdo; |
6 | 6 |
|
7 | 7 | use Override; |
| 8 | +use PDO; |
8 | 9 | use PDOStatement; |
9 | 10 | use PhpDb\Adapter\Driver\Feature\DriverFeatureProviderInterface; |
10 | 11 | use PhpDb\Adapter\Driver\Feature\DriverFeatureProviderTrait; |
11 | 12 | use PhpDb\Adapter\Driver\Pdo\AbstractPdo; |
12 | 13 | use PhpDb\Adapter\Driver\Pdo\Result; |
13 | 14 | use PhpDb\Adapter\Driver\Pdo\Statement; |
| 15 | +use PhpDb\Adapter\Driver\PdoConnectionInterface; |
| 16 | +use PhpDb\Adapter\Driver\PdoDriverAwareInterface; |
14 | 17 | use PhpDb\Adapter\Driver\ResultInterface; |
| 18 | +use PhpDb\Adapter\Driver\StatementInterface; |
15 | 19 | use PhpDb\Sqlite\DatabasePlatformNameTrait; |
16 | 20 |
|
17 | 21 | class Driver extends AbstractPdo implements DriverFeatureProviderInterface |
18 | 22 | { |
19 | 23 | use DatabasePlatformNameTrait; |
20 | 24 | use DriverFeatureProviderTrait; |
21 | 25 |
|
| 26 | + public function __construct( |
| 27 | + (PdoConnectionInterface&PdoDriverAwareInterface)|PDO $connection, |
| 28 | + (StatementInterface&PdoDriverAwareInterface)|Statement $statementPrototype = new Statement(), |
| 29 | + ResultInterface $resultPrototype = new Result(), |
| 30 | + array $features = [], |
| 31 | + ) { |
| 32 | + $this->connection = $connection; |
| 33 | + $this->statementPrototype = $statementPrototype; |
| 34 | + $this->resultPrototype = $resultPrototype; |
| 35 | + |
| 36 | + if (! $this->connection instanceof PDO) { |
| 37 | + $this->connection->setDriver($this); |
| 38 | + } |
| 39 | + |
| 40 | + $this->statementPrototype->setDriver($this); |
| 41 | + |
| 42 | + // $features is not constructor promoted because $this->features is defined in the trait |
| 43 | + if ($features !== []) { |
| 44 | + $this->addFeatures($features); |
| 45 | + } |
| 46 | + } |
| 47 | + |
22 | 48 | /** |
23 | 49 | * @param PDOStatement|resource $resource |
24 | 50 | */ |
|
0 commit comments