[TYPO3-core] RFC #13467: add getField() function to database API

Ernesto Baschny [cron IT] ernst at cron-it.de
Fri Apr 9 14:13:53 CEST 2010


Benjamin Mack schrieb am 26.03.2010 14:19:

>> Am 19.02.10 12:47, schrieb Benjamin Mack:
>>> just for one line less. Of course, I can be convinced other...
>>
>> I think in the end it's your descission as RM.
>>
>> IMO it would make sense ... if we wouldn't care about some lines more or
>> less, we could drop getRows() as well and use query() instead. ;-)
> In fact, I stopped using getRows(), as it is less performant, as I'm
> gonna loop through the rows again anyway at some point. I used getRows()
> for +60K fe_users (for an export module) and I got a memory_limit
> problem. After switching back to exec_SELECTquery and manually iterating
> over the DB result, it worked like a charm :).

We could make a cooler "getRows()" alternative which returns an object
that implements "Iterator" [1] and which internally does the
sql_fetch_assoc, sql_data_seek etc.

This would provide a much cleaner API, allowing stuff like:

 $rows = DB->exec_SELECTgetRowsIterator(blabla);
 foreach ($rows as $row) {
    // do stuff
 }

without memory harm, as the foreach will fetch each "$row" on demand.

Cheers,
Ernesto

[1] http://php.net/manual/de/language.oop5.iterations.php


More information about the TYPO3-team-core mailing list