1717 */
1818class ResultSet implements \Iterator
1919{
20- private readonly ?Drivers \Result $ result ;
21-
2220 /** @var callable(array, ResultSet): array */
2321 private readonly mixed $ normalizer ;
2422 private Row |false |null $ lastRow = null ;
2523 private int $ lastRowKey = -1 ;
2624
2725 /** @var Row[] */
2826 private array $ rows ;
29- private float $ time ;
3027 private array $ converters ;
3128
3229
3330 public function __construct (
3431 private readonly Connection $ connection ,
35- private readonly string $ queryString ,
36- private readonly array $ params ,
32+ private readonly Drivers \ Result $ result ,
33+ private readonly ? SqlLiteral $ query = null ,
3734 ?callable $ normalizer = null ,
35+ private ?float $ time = null ,
3836 ) {
39- $ time = microtime (true );
4037 $ this ->normalizer = $ normalizer ;
41- if (str_starts_with ($ queryString , ':: ' )) {
42- $ connection ->getConnectionDriver ()->{substr ($ queryString , 2 )}();
43- } else {
44- $ this ->result = $ connection ->getConnectionDriver ()->query ($ queryString , $ params );
45- }
46- $ this ->time = microtime (true ) - $ time ;
4738 }
4839
4940
@@ -55,27 +46,27 @@ public function getConnection(): Connection
5546 }
5647
5748
58- public function getQueryString (): string
49+ public function getQueryString (): ? string
5950 {
60- return $ this ->queryString ;
51+ return $ this ->query ?->getSql() ;
6152 }
6253
6354
6455 public function getParameters (): array
6556 {
66- return $ this ->params ;
57+ return $ this ->query ?->getParameters() ;
6758 }
6859
6960
7061 public function getColumnCount (): ?int
7162 {
72- return $ this ->result ? ->getColumnCount();
63+ return $ this ->result ->getColumnCount ();
7364 }
7465
7566
7667 public function getRowCount (): ?int
7768 {
78- return $ this ->result ? ->getRowCount();
69+ return $ this ->result ->getRowCount ();
7970 }
8071
8172
@@ -150,7 +141,7 @@ public function valid(): bool
150141 */
151142 public function fetch (): ?Row
152143 {
153- $ data = $ this ->result ? ->fetch();
144+ $ data = $ this ->result ->fetch ();
154145 if ($ data === null ) {
155146 return null ;
156147
@@ -174,7 +165,7 @@ public function fetch(): ?Row
174165 /** @internal */
175166 public function fetchAssociative (): ?array
176167 {
177- return $ this ->result ? ->fetch();
168+ return $ this ->result ->fetch ();
178169 }
179170
180171
0 commit comments