Limit on related table

Hi, I’m just starting with yii framework. I’ve previously used Codeigniter.

I ran into limit problem. The code that I’m using is the following:




$model = PostCategory::model();

  $record = $model->with(array(

    'posts'=>array(

      'order'=>'posts.createTime DESC',

      'limit'=>3,

))->findByPK($id);



I want to limit the posts queried for paging purposes. I’ve also tried to add


'together'=>true

after limit, this doesn’t help too.

Any help is appreciated.

Anyone? Any ideas?

I found the fix, thanks to bool.dev from stackoverflow.com.




$model = PostCategory::model();

$record = $model->with(array(

    'posts'=>array(

      'order'=>'posts.createTime DESC',

    ),

  ))->findByPK($id,

             array('limit'=>3,'together'=>true) // adding this works

);