From 1d43634ebd97cf67e2ba27f1880cc59b86b29f96 Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Tue, 19 Mar 2013 21:30:12 +0100 Subject: created a protected function to mark a field as updated --- db/entity.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'db') diff --git a/db/entity.php b/db/entity.php index 1adf9b518..2c6f4f899 100644 --- a/db/entity.php +++ b/db/entity.php @@ -45,11 +45,9 @@ abstract class Entity { if(strpos($methodName, 'set') === 0){ $setterPart = substr($methodName, 3); $attr = lcfirst($setterPart); - - // mark as accessed - array_push($this->updatedFields, $attr); - $this->$attr = $args[0]; + $this->markFieldUpdated($attr); + $this->$attr = $args[0]; } elseif(strpos($methodName, 'get') === 0) { $getterPart = substr($methodName, 3); $attr = lcfirst($getterPart); @@ -58,6 +56,15 @@ abstract class Entity { } + /** + * Mark am attribute as updated + * @param string $attribute the name of the attribute + */ + protected function markFieldUpdated($attribute){ + array_push($this->updatedFields, $attribute); + } + + /** * Transform a database columnname to a property * @param string $columnName the name of the column -- cgit v1.2.3