Yii在查询时限制相关模型

Arm*_* P. 5 php sql limit yii

我遇到了限制问题.我正在使用的代码如下:

$model = PostCategory::model();
  $record = $model->with(array(
    'posts'=>array(
      'order'=>'posts.createTime DESC',
      'limit'=>3,
))->findByPK($id);
Run Code Online (Sandbox Code Playgroud)

我想限制为查询目的查询的帖子.我也尝试过添加

'together'=>true
Run Code Online (Sandbox Code Playgroud)

在限制之后,这也没有帮助.

任何帮助表示赞赏.

boo*_*dev 6

这肯定会有效,只是测试过:

$model = PostCategory::model();
$record = $model->with(array(
  'posts'=>array(
     'order'=>'posts.createTime DESC',
  ))->findByPK($id,
             array('limit'=>3,'together'=>true) // adding this works
);
Run Code Online (Sandbox Code Playgroud)