[TYPO3-dev] DB query iterator; worth a try?

Martin Kutschker masi-no at spam-typo3.org
Fri Apr 23 15:47:19 CEST 2010


Ries van Twisk schrieb:
> 
> On Apr 23, 2010, at 2:13 AM, Jigal van Hemert wrote:
> 
>> Martin Kutschker wrote:
>>> You can already use exec_SELECTgetRows() if foreach() is all you need.
>>
>> ... which loads the entire result set in an array. TYPO3 is already
>> eating a lot of memory as it is.
>> The nice thing about an iterator is that it still only loads one
>> record at a time.
>> You don't need to do the call to the fetch-method yourself, because
>> that is handled also by the iterator.
> 
> In reality it really doesn't matter because the recordset is loaded into
> memory anyways.

With the underlying C-Api you can fetch single result sets, but the drawback is that now the DB
server will need to hold the complete result in memory (or temp. files) and you make a call to the
DB for each row.

So you gain only something if youo need only a few rows and can calculate the row numbers for the
seek() easily on the client side.

Anyway, the real advantage I see in using a class to access a query result is the abstraction and
encapsulation.

Masi




More information about the TYPO3-dev mailing list