PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Structures » Structures_DataGrid_DataSource_DataObject » Bug #8106

Moving creation of _options['fields'] outside of fetch() loop

Details

Submitted2006-07-03 08:46 UTC
Frommichel dot dhooge at gmail dot com
Assignedolivierg
StatusClosed
PackageStructures_DataGrid_DataSource_DataObject
PHP VersionIrrelevant
Roadmaps(Not assigned)

Comments

[2006-07-03 08:46 UTC] michel dot dhooge at gmail dot com

Description:
------------
The test "if (!$this->_options['fields'])" is inside the DB_DO::fetch() loop of the SDG_DS_DO::fetch() method. Since it is true at most on the first iteration, it could be moved before the loop (maybe within the bind() method).

The only reason I can see to leave the test within the loop is if some variables are not pre-defined in the DB_DO object (as it is always the case with the default object creation) and are created on the fly when DB_DO::fetch() is called. IMHO quite unlikely...

HTH

[2007-02-09 11:54 UTC] olivierg at php dot net

Hi,

I did not exactly move the test out of the fetch loop, because DBDO::fetch() must be call beofre DBDO::toArray(), and I dislike do {} while statements.

However I've implemented a simple boolean check so that this code segment is only ran on the initial iteration.

I also removed the unneeded $fieldList variable.

That's all in CVS. Thanks for your report