How To Get Relational Query Results Together

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

Probably you are misunderstanding lazy loading and eager loading of the relation.

http://www.yiiframework.com/forum/index.php/topic/34412-eager-loading-vs-lazy-loading