Hi all,
While using relational query we get separate results for the model and for the relation.
As the documentation says
// retrieve the post whose ID is 10
$posts=Post::model()->with('author')->findAll();
// retrieve the post's author: a relational query will be performed here
$author=$post->author;
And the relation is
public function relations()
{
return array(
'author'=>array(self::BELONGS_TO, 'User', 'author_id'),
);
}
This means that i have to again call $author = $post->author to get the relational data.(here author is the relation).
I want them to come together as an array or objects. Is it possible to do. Because in a normal sql method, i get all
data joined together and i just do a looping to fetch the data.
Thanks to All
Smith
While using relational query we get separate results for the model and for the relation.
As the documentation says
// retrieve the post whose ID is 10
$posts=Post::model()->with('author')->findAll();
// retrieve the post's author: a relational query will be performed here
$author=$post->author;
And the relation is
public function relations()
{
return array(
'author'=>array(self::BELONGS_TO, 'User', 'author_id'),
);
}
This means that i have to again call $author = $post->author to get the relational data.(here author is the relation).
I want them to come together as an array or objects. Is it possible to do. Because in a normal sql method, i get all
data joined together and i just do a looping to fetch the data.
Thanks to All
Smith