summaryrefslogtreecommitdiff
path: root/app/php/db/ActiveRecord.php
blob: 49e862c0a655a5af5fc95e9d728dc772c42c4ad9 (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($name, $value);
    }

}

?>