From 24fff442e08c3b3ba4c4ef5c663ba04fd410f31e Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Thu, 11 Jun 2015 22:00:36 +0200 Subject: [PATCH] DbObject: separate setting db properties --- library/Director/Data/Db/DbObject.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/library/Director/Data/Db/DbObject.php b/library/Director/Data/Db/DbObject.php index 283f4bd9..fb373789 100644 --- a/library/Director/Data/Db/DbObject.php +++ b/library/Director/Data/Db/DbObject.php @@ -477,14 +477,19 @@ abstract class DbObject protected function loadFromDb() { $select = $this->db->select()->from($this->table)->where($this->createWhere()); - $props = $this->db->fetchRow($select); + $properties = $this->db->fetchRow($select); - if (empty($props)) { + if (empty($properties)) { $msg = sprintf('Got no "%s" data for: %s', $this->table, $this->getId()); throw new Exception($msg); } - foreach ($props as $key => $val) { + return $this->setDbProperties($properties); + } + + protected function setDbProperties($properties) + { + foreach ($properties as $key => $val) { if (! array_key_exists($key, $this->properties)) { throw new Exception(sprintf( 'Trying to set invalid %s key "%s". DB schema change?',