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.
This will definitely work, just tested :
$model = PostCategory::model();
$record = $model->with(array(
'posts'=>array(
'order'=>'posts.createTime DESC',
))->findByPK($id,
array('limit'=>3,'together'=>true) // adding this works
);
Here is a wiki on parameterized named scopes.
But if you want to filter records in RELATED tables while using Relational Query, then you should use defaultScope().
Here is a wiki on defaultScope and it also shows how to bypass defaultScope when it is not needed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With