Answer the question
In order to leave comments, you need to log in
How to make yii2 REST fetch start, limit?
Good afternoon, how can I make a selection in Yii2, the client passes start and limit.
Answer the question
In order to leave comments, you need to log in
public function actionIndex() {
$query = Users::find();
$start = \Yii::$app->request->get('start');
$limit = \Yii::$app->request->get('length');
$pagination = new Pagination([
'totalCount' => $query->count(),
]);
$users['data'] = $query->offset($start)
->limit($limit)
->all();
$users['recordsTotal'] = $pagination->totalCount;
$users['recordsFiltered'] = $pagination->totalCount;
return $users;
}
sample where? in ActiveQuery?
if yes thenModel::find()->offset($start)->limit($limit)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question