My query:
$comments = Comment::model()->findAll(array(
'condition'=>'t.id=:id and t.status=2',
'group'=>'t.forum_id',
'select'=>'t.id, t.status, t.forum_id, t.comment_id',
'order'=>'t.id desc',
'with'=>array('forum'),
'alias'=>'t',
'params'=>array(':id'=>$id)
)
);
var_dump($comments->forum); exit; //Trying to get property of non-object
Comment model:
'forum' => array(self::BELONGS_TO, 'Forum', 'forum_id'),
Forum model:
'comment' => array(self::HAS_MANY, 'Comment', 'forum_id'),
Why dont use the related model?