Answer the question
In order to leave comments, you need to log in
Why does count return the same data regardless of conditions?
There are 6 records in the table. Here is the action:
public function actionAddMoreGroupPosts($id,$page){
$offset = ($page-1) * 20;
$query = GroupPost::find()->with(['author'])->where(['group_id'=>$id])->orderBy('status_id DESC, id DESC')->offset($offset);
return $query->count();
}
SELECT COUNT(*) FROM `group_post` WHERE `group_id`='2' ORDER BY `status_id` DESC, `id` DESC
Answer the question
In order to leave comments, you need to log in
а полученный запрос после конструктора не смотрели? Иногда помогает - визуально оценить что наваяли если все мысли кончились )
Try writing: return $query->count([0]); In general, I can’t understand what Count should be returned, id or some other field.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question