I have a database view created and when I use laravel pagination against this view, it throws:
SQLSTATE[42000]: Syntax error or access violation: 1140 Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause (SQL: select count(*) as aggregate from `parameter_log_site_detail` where `site_id` = EPE)
But this error pops up only in live server. Pagination works fine in local server.
DB View: (parameter_log_site_detail)
select `t`.`site_id` AS `site_id`,cast(`t`.`logged_at` as date) AS `logged_on`,`t`.`daily_generation` AS `daily_generation`,`t`.`reading` AS `tot_reading` from `parameter_log_tab` `t` order by cast(`t`.`logged_at` as date) desc
Model:
public function scopeSiteDailyReadings($query)
{
return $query->from('parameter_log_site_detail');
}
Controller:
$generations = EnergyGeneration::siteDailyReadings()->where('site_id', $site_id)->orderBy('logged_on', 'desc')->paginate(15);
Live server info
MySQL Server version: 5.6.37 - MySQL Community Server (GPL)
PHP version: 5.6.30
Laravel version: 5.4
Local server info (where it runs normally)
MySQL Server version: 5.7.19 - MySQL Community Server (GPL)
PHP version: 7.1.7
Laravel version: 5.4
Could someone explain what can be the reason for this? I read about ONLY_FULL_GROUP_BY. But cannot figure out is it the reason since the server version is 5.6.*.