From: Mikael Nordfeldth Date: Wed, 23 Mar 2016 14:19:50 +0000 (+0100) Subject: Allow actions to be performed on updateWithKeys X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=250d99d997f6a34b90af943c5428eaffda3238cc;p=quix0rs-gnu-social.git Allow actions to be performed on updateWithKeys Avoids overloading and lets dataobject classes use onUpdateKeys() to do special stuff, like if a key is made up of a hash of other fields etc. --- diff --git a/classes/Managed_DataObject.php b/classes/Managed_DataObject.php index 0857bb11f6..5b22672d7b 100644 --- a/classes/Managed_DataObject.php +++ b/classes/Managed_DataObject.php @@ -483,6 +483,8 @@ abstract class Managed_DataObject extends Memcached_DataObject throw new ServerException('DataObject must be the result of a query (N>=1) before updateWithKeys()'); } + $this->onUpdateKeys($orig); + // do it in a transaction $this->query('BEGIN'); @@ -580,6 +582,11 @@ abstract class Managed_DataObject extends Memcached_DataObject // NOOP by default } + protected function onUpdateKeys(Managed_DataObject $orig) + { + // NOOP by default + } + public function insert() { $this->onInsert();