Hello
I would like to do this, but I am blocked,
I’ve got a model with a relation like this:
class Post extends CActiveRecord
{
public function relations()
{
return array(
'users'=>array(self::HAS_MANY, 'User', 'userId'),
);
}
}
and now I have this method to get all post from an user;
public function getUserPost($id){
$posts = $this->findByPK($id);
var_dump($posts);//here I get all post information relate to user $id
}
But for example I want that in the result of function getUserPost, add also for example username, that is a field that is in user table, but I only have all the fields belongs to model Post, that means all fields from table post in database, but I need also in the result to add one of the relation fields.
My doubt: How can I do that !
Thank you in advance !