diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2013-03-19 20:32:44 +0100 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2013-03-19 20:32:44 +0100 |
commit | 50e00916ce1d4536acc2268161135a588fb0c12f (patch) | |
tree | 4948a618098435004c9a916a045adf010cd51565 /db/entity.php | |
parent | 966af078df176fc96d1e37696d4725115ad9639f (diff) |
added namespaced indices for the newsapp
Diffstat (limited to 'db/entity.php')
-rw-r--r-- | db/entity.php | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/db/entity.php b/db/entity.php index 9adab3b7f..58c42cca7 100644 --- a/db/entity.php +++ b/db/entity.php @@ -27,10 +27,56 @@ namespace OCA\News\Db; abstract class Entity { - public function fromRow($row){ + public $id; + + private $updatedFields; + + + public function __construct(){ + $this->updatedFields = array(); + } + + + /** + * Each time a setter is called, push the part after set + * into an array: for instance setId will save Id in the + * updated fields array so it can be easily used to create the + * getter method + */ + public function __call($methodName, $args){ + if(startsWith($methodName, 'set')){ + $setterPart = substr($methodName, 2); + array_push($this->updatedFields, $setterPart); + } + } + + + /** + * @return array array of updated fields for update query + */ + public function getUpdatedFields(){ + return $this->updatedFields; + } + + + /** + * Maps the keys of the row array to the attributes + * @param array $row the row to map onto the entity + */ + public function fromRow(array $row){ foreach($row as $key => $value){ $this->$key = $value; } } + + public function setId($id){ + $this->id = $id; + } + + + public function getId(){ + return $this->id; + } + }
\ No newline at end of file |