控制器(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>