• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

brick / geo / 14083182735

26 Mar 2025 12:23PM UTC coverage: 63.411% (+1.3%) from 62.112%
14083182735

push

github

BenMorel
Implement PgsqlDriver (pgsql extension)

40 of 53 new or added lines in 1 file covered. (75.47%)

41 existing lines in 3 files now uncovered.

1922 of 3031 relevant lines covered (63.41%)

1910.52 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

87.5
/src/Engine/Database/Driver/Internal/AbstractPdoDriver.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Brick\Geo\Engine\Database\Driver\Internal;
6

7
use Brick\Geo\Engine\Database\Driver\DatabaseDriver;
8
use Brick\Geo\Engine\Database\Query\BinaryValue;
9
use Brick\Geo\Engine\Database\Query\ScalarValue;
10
use Brick\Geo\Engine\Database\Result\Row;
11
use Brick\Geo\Exception\GeometryEngineException;
12
use Override;
13
use PDO;
14
use PDOException;
15

16
abstract class AbstractPdoDriver implements DatabaseDriver
17
{
18
    public function __construct(
19
        private readonly PDO $pdo,
20
    ) {
21
    }
×
22

23
    /**
24
     * Converts the query parts to a query string and parameters to send to PDO.
25
     *
26
     * @return array{string, list<array{scalar, PDO::PARAM_*}>}
27
     */
28
    abstract protected function convertQuery(string|BinaryValue|ScalarValue ...$query) : array;
29

30
    #[Override]
31
    public function executeQuery(string|BinaryValue|ScalarValue ...$query) : Row
32
    {
UNCOV
33
        [$queryString, $queryParams] = $this->convertQuery(...$query);
1,484✔
34

35
        /** @var int $errMode */
UNCOV
36
        $errMode = $this->pdo->getAttribute(PDO::ATTR_ERRMODE);
1,484✔
UNCOV
37
        $this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
1,484✔
38

39
        try {
UNCOV
40
            $statement = $this->pdo->prepare($queryString);
1,484✔
41

UNCOV
42
            $position = 1;
1,345✔
43

UNCOV
44
            foreach ($queryParams as [$value, $type]) {
1,345✔
UNCOV
45
                $statement->bindValue($position++, $value, $type);
1,337✔
46
            }
47

UNCOV
48
            $statement->execute();
1,345✔
49

50
            /** @var list<list<mixed>> $result */
UNCOV
51
            $result = $statement->fetchAll(PDO::FETCH_NUM);
1,094✔
52
        } catch (PDOException $e) {
410✔
53
            throw GeometryEngineException::wrap($e);
410✔
54
        } finally {
UNCOV
55
            $this->pdo->setAttribute(PDO::ATTR_ERRMODE, $errMode);
1,484✔
56
        }
57

UNCOV
58
        if (count($result) !== 1) {
1,094✔
59
            throw new GeometryEngineException(sprintf('Expected exactly one row, got %d.', count($result)));
×
60
        }
61

UNCOV
62
        return new Row($this, $result[0]);
1,094✔
63
    }
64
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc