diff --git a/Model/SqlModel.php b/Model/SqlModel.php index 3f99f75..5991557 100644 --- a/Model/SqlModel.php +++ b/Model/SqlModel.php @@ -174,6 +174,22 @@ abstract class SqlModel extends Model $cache_key->set($result); } } + + $calledClassName = get_called_class(); + + if ($result) { + $orm = new $calledClassName; + + foreach (get_object_vars($result) as $key => $value) { + if ($key == 'table') { + $key = 'table_field'; + } + $orm->$key = $value; + } + + return $orm; + } + return $result; } @@ -250,4 +266,4 @@ abstract class SqlModel extends Model { return new SqlCriteria($this, $sql_expression, $sql_expression_params); } -} \ No newline at end of file +}