<?php
/**
* 描述...
* @author zcy
* @date 2019/8/13
*/
namespace app\controllers;
use app\models\ShopInfo;
use yii\web\Controller;
use yii\base\Model;
use yii\web\NotAcceptableHttpException;
use yii\data\Pagination;
use yii\widgets\LinkPager;
class UserController extends Controller
{
public function actionPagination()
{
$query = ShopInfo::find()->where(['shop_type' => 1]);
$count = $query->count();
//每页显示量为10
$pagination = new Pagination(['totalCount' => $count,'defaultPageSize' => 10]);
$shop_info = $query->offset($pagination->offset)
->select('shop_name,shop_type')
->limit($pagination->limit)
->asArray()
->all();
dd($shop_info);
//创建支持分页的 UI 元素,自动分成多少页
echo LinkPager::widget(['pagination' => $pagination]);
}
}