/** * get property * @param string name property name * @return mixed property value */ public function __get($name) { /** * First job is to return the value if it exists in the table */ if (array_key_exists($name, $this->row)) { return stripslashes($this->row[$name]); } /** * Then we see if the attribute has a dedicated method */ if (method_exists($this, $name)) { return $this->{$name}(); } /** * Then we see if it has been setup as a has_many relationship. * This is passed on to the has_many_methods method which will * perform an operation on the associated table based on the join table. */ if (array_key_exists($name, $this->has_many_throughs)) { return $this->has_many_methods("get", $name); } /** * Next we try and link to a child object of the same name */ $link = $name . "_id"; $id = $this->row[$this->primary_key]; $class_name = WXInflections::camelize($name, true); if ($own = $this->row[$link]) { if (class_exists($class_name, false)) { return WXActiveRecord::get_owner($class_name, $this->pdo, $own); } } if ($id) { $foreign_key = $this->table . '_id'; if (class_exists($class_name, false)) { return WXActiveRecord::get_relation($class_name, $this->pdo, $foreign_key, $id); } } return false; }