diff options
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); + } + +} + +?> |