DataObject and update()
| From: | kundert at mysunrise dot ch | Date: | Thu, 18 Nov 2004 11:18:57 +0000 |
| Subject: | DataObject and update() | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-15627@lists.php.net to get a copy of this message | ||
Hi all
I allways wondering about the generated update sql strings from Dataobject. Even I changed one
column in the table, all columns are included in the update sql string. Then I saw in the source
from Dataobject.php function update() the follwing code:
// dont write things that havent changed..
if (($dataObject !== false) && isset($dataObject->$k) && ($dataObject->$k ==
$this->$k))
{
continue;
}
So, I tried this:
$do_herde_kosten_old = clone $do_herde_kosten;
$do_herde_kosten->setFrom($values,'frm_%s');
$do_herde_kosten->update($do_herde_kosten_old);
and it works, only the changed columns are in the update SQL. But is this the right way?
Shouldn't update() do this by it self? And for what else should the update() parameter be
usefully?
Marco
_____________________________________________________________
Neu! sunrise SMS-Abos mit bis zu 250 SMS monatlich inklusive.
http://www.sunrise.ch/message