Simple story. I have users and blog-posts, users are related to blog-posts as ONE to MANY. I would like to show users their profile along with the 5 most recent posts they wrote:
/**
* @return array relational rules.
*/
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'posts' => array(self::HAS_MANY, 'BlogPost', 'userId')
);
}
I am trying to apply limit:
$user = User::model()->with(array(
'posts' => array('order' => 'updatedAt DESC'),
->findAll(array(
'condition' => 'userId = :userId AND ...',
'params' => array(
'userId' => $userId
),
'limit' => 5
));
But Yii framework ignores that. How can I accomplish it?
It's Yii 1.1.