public function actionIndex() { $query = TblBlog::find(); $hotquery = clone $query; $hots = $hotquery->select(['id', 'title'])->orderBy('pri desc')->limit(3)->asArray()->all(); $pages = new Pagination(['totalCount' => $query->count()]); $pages->setPageSize(5); $articles = $query->offset($pages->offset)->limit($pages->limit)->orderBy('id DESC')->asArray()->all(); foreach ($articles as $key => $value) { $articles[$key]['text'] = mb_substr($value['text'], 0, 100, 'UTF-8'); } $motto = TblMotto::getrandmotto(); $categories = TblCategory::find()->asArray()->all(); return $this->render('index', ['articles' => $articles, 'motto' => $motto, 'pages' => $pages, 'hots' => $hots, 'categories' => $categories]); }