diff options
author | emkael <emkael@tlen.pl> | 2016-03-15 22:06:47 +0100 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2016-03-15 22:06:47 +0100 |
commit | cc09e963e8ef7ea093c7b13096856e5c732cd776 (patch) | |
tree | 9da36344800f23ed05b00df914e2b9c71e86ccee /app/php/db/ActiveRecord.php | |
parent | 6dcabb240f0ff0ee1654ac66f806bedb22495d23 (diff) |
* extending TActiveRecord so it's capable of fetching mapped column fields from sql maps
Diffstat (limited to 'app/php/db/ActiveRecord.php')
-rw-r--r-- | app/php/db/ActiveRecord.php | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/app/php/db/ActiveRecord.php b/app/php/db/ActiveRecord.php new file mode 100644 index 0000000..f5d06a3 --- /dev/null +++ b/app/php/db/ActiveRecord.php @@ -0,0 +1,30 @@ +<?php + +class ActiveRecord extends TActiveRecord { + + private function _getMappedPropertyName($name) { + if (isset(static::$COLUMN_MAPPING[$name])) { + return static::$COLUMN_MAPPING[$name]; + } + return $name; + } + + public function __get($name) { + $name = $this->_getMappedPropertyName($name); + if (property_exists($this, $name)) { + return $this->$name; + } + return parent::__get($name); + } + + public function __set($name, $value) { + $name = $this->_getMappedPropertyName($name); + if (property_exists($this, $name)) { + return $this->$name = $value; + } + return parent::__set($this->_getMappedPropertyName($name), $value); + } + +} + +?> |