你好,我有代码
$allLogins = IpAddressLogin::model()->findAllByAttributes(
array(
'user_id' => Yii::app()->user->id,
'type' => 'user'
),
array(
'order' => 'date desc',
'limit' => '15, 10',
));
Run Code Online (Sandbox Code Playgroud)
我想从15号记录中获得10条记录.但它只给了我最后15条记录.
它仅解析'limit'中的第一个数字(15).如何在findAllByAttributes中设置LIMIT 15,10?
Che*_*eta 18
你应该使用偏移量.请查看下面的代码,它将帮助您设置所需的限制
$allLogins = IpAddressLogin::model()->findAllByAttributes(
array(
'user_id' => Yii::app()->user->id,
'type' => 'user'
),
array(
'order' => 'date desc',
'limit' => 10,
'offset' => 15
));
Run Code Online (Sandbox Code Playgroud)