yii2多表联查分页

加载分页类

use yii\data\Pagination;

控制器层

public function actionPage()
    {
      $data = Add::find()->select('*')->innerJoin('zss_gift','zss_add.gift_id=zss_gift.gift_id'); //联查
       $pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '2']);
       $model = $data->offset($pages->offset)->limit($pages->limit)->asArray()->all(); //分页

       return $this->render('page',[
             'model' => $model,
             'pages' => $pages,
       ]);
    }
视图层



 $value) : ?>
  
//遍历 $pages, ]); ?>



你可能感兴趣的:(yii2多表联查分页)