Re: DataObject update
| From: | Justin Patrin | Date: | Thu, 17 Mar 2005 19:02:41 +0000 |
| Subject: | Re: DataObject update | ||
| References: | 1 2 3 4 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-36725@lists.php.net to get a copy of this message | ||
On Thu, 17 Mar 2005 19:12:30 +0100, Esad Hajdarevic
<esad-public@25novembar.com> wrote:
> Justin Patrin wrote:
>
> > Just expaning on the "edge case" idea. This *is* an edge case. If you
> > have two DataObjects which represent the same record you're probably
> > not using DB_DataObject correctly. It makes much more sense to use two
> > copied of the same DO.
> > $do =& DB_DataObject::factory('table');
> > $do->get(5);
> > ...
> > $do2 =& $do;
> > $do2->col = 'val';
>
> I think we misunderstood each other.
> I'm talking about something like:
>
> <code>
>
> $d=new DataObjects_Dealer;
>
> $fb=& DB_DataObject_FormBuilder::create($d);
> $form =& $fb->getForm();
>
> if ($form->validate()) {
> $form->process(array(&$fb,'processForm'), false);
> }
>
> //at this point form is validated an the dataobject is processed
> //now I have to show the list of all dealers
>
> $d->find();
> while ($d->fetch()) {
> ...
> }
>
> </code>
>
> The $d->find() wont work because of the data object manipulation done
> by processForm.
>
> So instead of typing something like
>
> $d->rewind();
>
> one has to create new data object?
>
Ok, this is a different case. In this case, that DataObject has
alreayd been used for a specific record and cannot be re-used for a
find()/fetch() unless you unset its member vars. It's generally bad
practice, though, to use the same dataobject for multiple different
uses.
--
Justin Patrin