If I select certain fields from joined table as:
<?php
return $this->getModelsManager()->createBuilder()
->columns('user.*, profile.name, profile.surname')
->addFrom('User', 'user')
->leftJoin('Profile', '', 'profile')
->where("user.id = :id:", array('id' => $id))
->getQuery()->execute();
?>
... i get:
<?php
object(Phalcon\Mvc\Model\Row)[105]
public 'profile_name' => string 'Name' (length=4)
public 'profile_surname' => string 'Surname' (length=6)
public 'user' =>
object(User)[242]
protected 'id' => int 1
protected 'login' => string 'login' (length=10)
?>
But I want to group profile fields into model as User model, like:
<?php
object(Phalcon\Mvc\Model\Row)[105]
public 'user' =>
object(User)[242]
protected 'id' => int 1
protected 'login' => string 'login' (length=10)
public 'profile' =>
object(Profile)[242]
protected 'name' => string 'Name' (length=4)
protected 'surname' => string 'Surname' (length=6)
protected 'other1' => string '' (length=0)
protected 'other2' => string '' (length=0)
protected 'other3' => string '' (length=0)
?>
How can I do this?