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 $ types ;
3128
3229
3330 public function __construct (
34- private readonly Connection $ connection ,
35- private readonly string $ queryString ,
36- private readonly array $ params ,
31+ private readonly Drivers \Result $ result ,
32+ private readonly ?SqlLiteral $ query = null ,
3733 ?callable $ normalizer = null ,
34+ private ?float $ time = null ,
3835 ) {
39- $ time = microtime (true );
4036 $ 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 ;
4737 }
4838
4939
@@ -54,27 +44,27 @@ public function getConnection(): Connection
5444 }
5545
5646
57- public function getQueryString (): string
47+ public function getQueryString (): ? string
5848 {
59- return $ this ->queryString ;
49+ return $ this ->query ?->getSql() ;
6050 }
6151
6252
6353 public function getParameters (): array
6454 {
65- return $ this ->params ;
55+ return $ this ->query ?->getParameters() ;
6656 }
6757
6858
6959 public function getColumnCount (): ?int
7060 {
71- return $ this ->result ? ->getColumnCount();
61+ return $ this ->result ->getColumnCount ();
7262 }
7363
7464
7565 public function getRowCount (): ?int
7666 {
77- return $ this ->result ? ->getRowCount();
67+ return $ this ->result ->getRowCount ();
7868 }
7969
8070
@@ -149,7 +139,7 @@ public function valid(): bool
149139 */
150140 public function fetch (): ?Row
151141 {
152- $ data = $ this ->result ? ->fetch();
142+ $ data = $ this ->result ->fetch ();
153143 if ($ data === null ) {
154144 return null ;
155145
@@ -173,7 +163,7 @@ public function fetch(): ?Row
173163 /** @internal */
174164 public function fetchAssociative (): ?array
175165 {
176- return $ this ->result ? ->fetch();
166+ return $ this ->result ->fetch ();
177167 }
178168
179169
0 commit comments