forked from php-db/phpdb-sqlite
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDriver.php
More file actions
42 lines (34 loc) · 1.28 KB
/
Driver.php
File metadata and controls
42 lines (34 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
declare(strict_types=1);
namespace PhpDb\Sqlite\Pdo;
use Override;
use PDOStatement;
use PhpDb\Adapter\Driver\Feature\DriverFeatureProviderInterface;
use PhpDb\Adapter\Driver\Feature\DriverFeatureProviderTrait;
use PhpDb\Adapter\Driver\Pdo\AbstractPdo;
use PhpDb\Adapter\Driver\Pdo\Result;
use PhpDb\Adapter\Driver\Pdo\Statement;
use PhpDb\Adapter\Driver\ResultInterface;
use PhpDb\Sqlite\DatabasePlatformNameTrait;
class Driver extends AbstractPdo implements DriverFeatureProviderInterface
{
use DatabasePlatformNameTrait;
use DriverFeatureProviderTrait;
/**
* @param PDOStatement|resource $resource
*/
#[Override]
public function createResult($resource, Statement|string|null $context = null): ResultInterface
{
/** @var ResultInterface&Result $result */
$result = clone $this->resultPrototype;
/** @var Feature\SqliteRowCounter $sqliteRowCounter */
$sqliteRowCounter = $this->getFeature(Feature\SqliteRowCounter::class);
$rowCount = 0;
if ($sqliteRowCounter && $resource->columnCount() > 0) {
$rowCount = $sqliteRowCounter->getRowCountClosure($context);
}
$result->initialize($resource, $this->connection->getLastGeneratedValue(), $rowCount);
return $result;
}
}