summaryrefslogtreecommitdiff
path: root/app/php/db/ActiveRecord.php
blob: f5d06a302f5ac697f963704d373bfe72516e2f4c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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);
    }

}

?>