示例#1
0
 public function actionCities()
 {
     $query = Top::find();
     $pagination = new Pagination(['defaultPageSize' => 5, 'totalCount' => $query->count()]);
     $top = $query->orderBy('views DESC')->offset($pagination->offset)->limit($pagination->limit)->all();
     return $this->render('cities', ['top' => $top, 'pagination' => $pagination]);
 }
示例#2
0
文件: TopWidget.php 项目: HAJIOM/yii2
 public function run()
 {
     $query = Top::find();
     $top = $query->orderBy('views DESC')->limit(6)->all();
     return $this->render('top', ['top' => $top]);
 }