Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

How To Get Relational Query Results Together

$
0
0
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

Viewing all articles
Browse latest Browse all 18717

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>