Answer the question
In order to leave comments, you need to log in
Yii2 how to make pagination for grouped rows?
Hello,
I have a database table with events:
No problem displaying them line by line with pagination using the standard YII tool:
$query = Events::find()
->where(['eventActive'=> 1])
->orderBy('eventDate DESC');
$count = $query->count();
$pagination = new Pagination(['totalCount' => $count, 'forcePageParam'=> false, 'defaultPageSize'=>10]);
$eventsData = $query->offset($pagination->offset)
->limit($pagination->limit)
->all();
return $this->render('index', [
'eventsData' => $eventsData,
'pagination' => $pagination,
]);
Answer the question
In order to leave comments, you need to log in
I did as you described in two queries, you can of course stir up everything with joins and then make the whole thing in code, but it's not worth it (I did it with code, but then another programmer got it for a long time)))).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question