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

Jigal van Hemert jigal at xs4all.nl
Thu Apr 22 23:23:11 CEST 2010


Ries van Twisk wrote:
> On Apr 22, 2010, at 11:31 AM, Jigal van Hemert wrote:
>> Well, since you're the expert on DBAL: Can you tell if the other
>> DBMS-es support somehow a method to tell if there is a new record
>> available? If that is the case, an iterator can be  used.
> I believe for some databases that don't support cursors the whole 
> dataset will be loaded into PHP anyways.

I don't think the dataset is loaded in PHP allocated memory. It's more
likely that the database client receives the entire dataset or a large
part of it. That will be handled by the database client.
Anyway, these are details that we don't have to worry about :-)

> In fact, if my memory serves right is that for the current 
> implementations in PHP for normal queries (not cursor based) the
> whole dataset will be read into memory using one call to the RDBM and
> you can iterate over them because the DS is already there. There is
> not real 'need' from the RDBM to support this. Using cursors is a
> whole different story.

To use an iterator in PHP you only need to be able to tell if there is a 
next item.
As explained PHP will call next(), valid() (which must tell if there is 
a next item) and if valid() returns true, it will call current() and key().

I don't expect any problems for any database client in PHP with this.

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




More information about the TYPO3-dev mailing list