zoukankan      html  css  js  c++  java
  • YII2连表分页

    控制器(controller)页面

    use yiidataPagination;  //引入这个类

    public function actionList(){

            $data = Clock::find()->select('*')->innerJoin('user','clock.user_id=user.id'); //联查  

            $pages = new Pagination(['totalCount'=>$data->count(),'pageSize'=>3]);

            $res = $data->offset($pages->offset)->limit($pages->limit)->asArray()->all();

            return $this->render('list',['data'=>$res,'pages'=>$pages]);

    }

    视图(views)层

    <?= yiiwidgetsLinkPager::widget([

            'pagination' => $pages, 

            'nextPageLabel' => '下一页', 

            'prevPageLabel' => '上一页', 

            'firstPageLabel' => '首页', 

            'lastPageLabel' => '尾页'

    ]);?>

    <div style="float:left;padding-left:400px;"><?= yiiwidgetsLinkPager::widget([
    'pagination' => $pages,
    'nextPageLabel' => '下一页',
    'prevPageLabel' => '上一页',
    'firstPageLabel' => '首页',
    'lastPageLabel' => '尾页'
    ]);?></div>
  • 相关阅读:
    对象的思考1
    第一个php网页
    php&mysql
    python —print
    实现窗口移动
    numpy学习(二)
    numpy学习(一)
    knn算法之预测数字
    机器学习(一)之KNN算法
    matplot绘图(五)
  • 原文地址:https://www.cnblogs.com/hangxing1996/p/6796054.html
Copyright © 2011-2022 走看看