yii实现分页。出现问题。
代码如下,详细看魏曦restful 第四课,5:45。
<?php
namespace api\controllers;
use common\models\Article;
use yii\data\ActiveDataProvider;
use yii\rest\ActiveController;
class ArticleController extends ActiveController
{
public $modelClass='common\models\Article';
public function actions()
{
$actions=parent::actions();
unset($actions['index']);
return $actions;
}
public function actionIndex()
{
$modelClass=$this->modelClass;
return new ActiveDataProvider([
'query'=>$modelClass::find()->asArray(),
'pagination'=>['pageSize'=>5],
]);
}
}
The "query" property must be an instance of a class that implements the QueryInterface e.g. yii\db\Query or its subclasses.
但是报错呀……
怎么办?