1 year ago

Group by and Paginate

Posted 1 year ago by fdusautoir

Hi Everybody,

I have an issue using group by with paginate.

This works well :

$headlines = ProgramHeadline::all()->groupBy('month');

But when I try :

$headlines = ProgramHeadline::groupBy('month')->paginate(6);

I have this error :

SQLSTATE[42000]: Syntax error or access violation: 1055 'auan.program_headlines.id' isn't in GROUP BY (SQL: select * from `program_headlines` group by `month` limit 6 offset 0)

So far, if I test this request in Sequel Pro : That's working ! I searched about this issue and I've turn off the strict mode in config/database.php, that's working but I consider that's not a good solution as Taylor said in a comment.

So, what's going wrong here ?

Thanks for your help :)

Please sign in or create an account to participate in this conversation.