Home » Database » DB_DataObject » Bug #3983
"rewinding"
Details
| Request #3983 | "rewinding" |
|---|---|
| Submitted | 2005-03-28 19:51 UTC |
| From | esad-public at 25novembar dot com |
| Status | Wont fix |
| Package | DB_DataObject |
| PHP Version | Irrelevant |
| OS | Irrelevant |
| 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();
}