PEAR is archived and read-only

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

Home » Database » DB_DataObject » Bug #3983

"rewinding"

Details

Request #3983"rewinding"
Submitted2005-03-28 19:51 UTC
Fromesad-public at 25novembar dot com
StatusWont fix
PackageDB_DataObject
PHP VersionIrrelevant
OSIrrelevant
Roadmaps(Not assigned)

Comments

[2005-03-28 19:51 UTC] esad-public at 25novembar dot com

Description:
------------
Once we iterate throught the DBO using fetch(), it should be possible to "rewind" the DBO without re-creating it. This could be useful for two-pass calculations.

Reproduce code:
---------------
$d=new DataObjects_Person;

$totalHeight=0;
$count=0;

while ($d->fetch(AUTO_FETCH)) {
$totalHeight=$totalHeight+$d->Height;
$count++;
}

$average=$totalHeight/$count;

// how to "rewind" this DBO?
// In this case we can re-create the DBO, but what if we
// had some select and whereAdds? we have to apply them
// again

$d=new DataObjects_Person;

while ($d->fetch(AUTO_FETCH)) {
$d->Deviation=($d->Height)/$average;
$d->update();
}