加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

Yii findAllByAttributes LIMIT

发布时间:2020-12-13 18:23:25 所属栏目:PHP教程 来源:网络整理
导读:你好,我有代码 $allLogins = IpAddressLogin::model()-findAllByAttributes( array( 'user_id' = Yii::app()-user-id,'type' = 'user' ),array( 'order' = 'date desc','limit' = '15,10',)); 我想从15号记录中获得10条记录.但它只给了我最后15条记录. 它仅
你好,我有代码
$allLogins = IpAddressLogin::model()->findAllByAttributes(
    array(
        'user_id' => Yii::app()->user->id,'type' => 'user'
    ),array(
        'order' => 'date desc','limit' => '15,10',));

我想从15号记录中获得10条记录.但它只给了我最后15条记录.

它仅解析’limit’中的第一个数字(15).如何在findAllByAttributes中设置LIMIT 15,10?

你应该使用偏移量.请查看下面的代码,它将帮助您设置所需的限制
$allLogins = IpAddressLogin::model()->findAllByAttributes(
array(
    'user_id' => Yii::app()->user->id,'type' => 'user'
),array(
    'order' => 'date desc','limit' => 10,'offset' => 15
));

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读