Answer the question
In order to leave comments, you need to log in
It throws an error when executing the search function, what's the problem?
Search function code
public function actionSearch(){
$q = Yii::$app->request->get('q');
$query = Product::find()->where(['like', 'name', $q]);
$pages = new Pagination(['totalCount' => $query->count(), 'pageSize'=>3,'forcePageParam' => false, 'pageSizeParam' => false]);
$products = $query->offset($pages->offset)->limit($pages->limit)->all();
return $this->render('search', compact('products','pages','q'));
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question