@@ -118,86 +118,7 @@ public function fetchValue($default = null, ?callable $fn = null);
118118 public function getFoundRows (): int ;
119119
120120 /**
121- * @return Traversable|array[]
122- */
123- public function getIterator () {
124- /** @var Traversable|array[] $result */
125- $ result = $ this ->fetchRowsLazy ();
126- return $ result ;
127- }
128-
129- /**
130- * @param Closure|null $callback
131- * @param int $mode
132- * @param mixed $arg0
133- * @return mixed
134- */
135- private function fetchAll (Closure $ callback = null , int $ mode = 0 , $ arg0 = null ) {
136- return $ this ->createTempStatement (function (QueryStatement $ statement ) use ($ callback , $ mode , $ arg0 ) {
137- $ statement ->setFetchMode ($ mode , $ arg0 );
138- $ data = $ statement ->fetchAll ();
139- if ($ this ->preserveTypes ) {
140- $ columnDefinitions = FieldTypeProvider::getFieldTypes ($ statement );
141- $ data = array_map (static function ($ row ) use ($ columnDefinitions ) {
142- return FieldValueConverter::convertValues ($ row , $ columnDefinitions );
143- }, $ data );
144- }
145- if ($ callback !== null ) {
146- return call_user_func (static function ($ resultData = []) use ($ data , $ callback ) {
147- foreach ($ data as $ row ) {
148- $ result = $ callback ($ row );
149- if ($ result !== null && !($ result instanceof DBIgnoreRow)) {
150- $ resultData [] = $ result ;
151- } else {
152- $ resultData [] = $ row ;
153- }
154- }
155- return $ resultData ;
156- });
157- }
158- return $ data ;
159- });
160- }
161-
162- /**
163- * @param Closure|null $callback
164- * @param int $mode
165- * @param mixed $arg0
166- * @return Traversable|mixed[]
167- */
168- private function fetchLazy (Closure $ callback = null , int $ mode = PDO ::FETCH_ASSOC , $ arg0 = null ) {
169- $ statement = $ this ->createStatement ();
170- $ statement ->setFetchMode ($ mode , $ arg0 );
171- $ generator = new LazyRowGenerator ($ this ->preserveTypes );
172- return $ generator ->generate ($ statement , $ callback );
173- }
174-
175- /**
176- * @param Closure|null $callback
177- * @param int $mode
178- * @param mixed $arg0
179- * @param Closure|null $resultValidator
180- * @return mixed
181- */
182- private function fetch (Closure $ callback = null , int $ mode = PDO ::FETCH_ASSOC , $ arg0 = null , Closure $ resultValidator = null ) {
183- return $ this ->createTempStatement (function (QueryStatement $ statement ) use ($ callback , $ mode , $ arg0 , $ resultValidator ) {
184- $ statement ->setFetchMode ($ mode , $ arg0 );
185- $ row = $ statement ->fetch ();
186- $ result = $ resultValidator ($ row );
187- if (!$ result ['valid ' ]) {
188- return $ result ['default ' ];
189- }
190- if ($ this ->preserveTypes ) {
191- $ columnDefinitions = FieldTypeProvider::getFieldTypes ($ statement );
192- $ row = FieldValueConverter::convertValues ($ row , $ columnDefinitions );
193- }
194- if ($ callback !== null ) {
195- $ result = $ callback ($ row );
196- if ($ result !== null ) {
197- $ row = $ result ;
198- }
199- }
200- return $ row ;
201- });
202- }
121+ * @return Generator<int, array<string, mixed>>
122+ */
123+ public function getIterator ();
203124}
0 commit comments