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

Jigal van Hemert jigal at xs4all.nl
Thu Apr 22 20:58:36 CEST 2010


Ernesto Baschny [cron IT] wrote:
> It should work. To make it perform just like regular fetch_assocs in a
> row: In next() you should do the sql_fetch_assoc right away so that you
> don't ever need to seek. A basic "foreach()" will just call next() +
> current() in a row.

Nope. [1] (yours) shows that the first iteration calls:
rewind(); if (valid()) { current(); key() }
and each following iteration calls:
next(); if (valid()) { current(); key() }

But it was just a simple test to see if it could work.

> And use $TYPO3_DB->sql_data_seek and $TYPO3_DB->sql_fetch_assoc while
> you are at it, so it is DBAL compliant.

Again, it was just a proof of concept. The variation in how a long a 
series of queries took with either method was so large that it was hard 
to tell which one was the faster of the two.

> [1] http://www.php.net/manual/de/class.iterator.php#89053

-- 
Jigal van Hemert
skype:jigal.van.hemert
msn: jigal at xs4all.nl
http://twitter.com/jigalvh




More information about the TYPO3-dev mailing list