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

dg / dibi / 22284472534

22 Feb 2026 08:11PM UTC coverage: 76.31% (-0.2%) from 76.552%
22284472534

push

github

dg
phpstan

56 of 106 new or added lines in 23 files covered. (52.83%)

82 existing lines in 8 files now uncovered.

1762 of 2309 relevant lines covered (76.31%)

0.76 hits per line

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

79.17
/src/Dibi/Drivers/PdoResult.php
1
<?php declare(strict_types=1);
2

3
/**
4
 * This file is part of the Dibi, smart database abstraction layer (https://dibi.nette.org)
5
 * Copyright (c) 2005 David Grudl (https://davidgrudl.com)
6
 */
7

8
namespace Dibi\Drivers;
9

10
use Dibi;
11
use Dibi\Helpers;
12
use PDO;
13

14

15
/**
16
 * The driver for PDO result set.
17
 */
18
class PdoResult implements Dibi\ResultDriver
19
{
20
        public function __construct(
1✔
21
                private \PDOStatement $resultSet,
22
                private readonly string $driverName,
23
        ) {
24
        }
1✔
25

26

27
        /**
28
         * Returns the number of rows in a result set.
29
         */
30
        public function getRowCount(): int
31
        {
32
                return $this->resultSet->rowCount();
1✔
33
        }
34

35

36
        /**
37
         * Fetches the row at current position and moves the internal cursor to the next position.
38
         * @param  bool  $assoc  true for associative array, false for numeric
39
         */
40
        public function fetch(bool $assoc): ?array
1✔
41
        {
42
                return Helpers::false2Null($this->resultSet->fetch($assoc ? PDO::FETCH_ASSOC : PDO::FETCH_NUM));
1✔
43
        }
44

45

46
        /**
47
         * Moves cursor position without fetching row.
48
         */
49
        public function seek(int $row): bool
50
        {
51
                throw new Dibi\NotSupportedException('Cannot seek an unbuffered result set.');
×
52
        }
53

54

55
        /**
56
         * Frees the resources allocated for this result set.
57
         */
58
        public function free(): void
59
        {
NEW
60
                unset($this->resultSet);
×
61
        }
62

63

64
        /**
65
         * Returns metadata for all columns in a result set.
66
         * @throws Dibi\Exception
67
         */
68
        public function getResultColumns(): array
69
        {
70
                $count = $this->resultSet->columnCount();
1✔
71
                $columns = [];
1✔
72
                for ($i = 0; $i < $count; $i++) {
1✔
73
                        $row = @$this->resultSet->getColumnMeta($i); // intentionally @
1✔
74
                        if ($row === false) {
1✔
75
                                throw new Dibi\NotSupportedException('Driver does not support meta data.');
×
76
                        }
77

78
                        $row += [
79
                                'table' => null,
1✔
80
                                'native_type' => 'VAR_STRING',
81
                        ];
82

83
                        $columns[] = [
1✔
84
                                'name' => $row['name'],
1✔
85
                                'table' => $row['table'],
1✔
86
                                'nativetype' => $row['native_type'],
1✔
87
                                'type' => $row['native_type'] === 'TIME' && $this->driverName === 'mysql' ? Dibi\Type::TimeInterval : null,
1✔
88
                                'fullname' => $row['table'] ? $row['table'] . '.' . $row['name'] : $row['name'],
1✔
89
                                'vendor' => $row,
1✔
90
                        ];
91
                }
92

93
                return $columns;
1✔
94
        }
95

96

97
        /**
98
         * Returns the result set resource.
99
         */
100
        public function getResultResource(): ?\PDOStatement
101
        {
NEW
102
                return $this->resultSet ?? null;
×
103
        }
104

105

106
        /**
107
         * Decodes data from result set.
108
         */
109
        public function unescapeBinary(string $value): string
110
        {
111
                return $value;
×
112
        }
113
}
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