public function __get($property)
{
$result = $this->orm->get($property);
if ($result !== null) {
if (method_exists($this, $method = 'get_' . $property)) {
return $this->{$method}($result);
} else {
return $result;
}
} elseif (method_exists($this, $method = 'missing_' . $property)) {
return $this->{$method}();
} elseif (array_key_exists($property, $this->relationships)) {
return $this->relationships[$property];
} elseif (method_exists($this, $property)) {
if ($property != self::_get_id_column_name(get_class($this))) {
$relation = $this->{$property}();
return $this->relationships[$property] = in_array($this->relating, array('has_one', 'belongs_to')) ? $relation->find_one() : $relation->find_many();
} else {
return null;
}
} else {
return null;
}
}