How can I solve incompatible with sql_mode=only_full_group_by in laravel eloquent?

前端 未结 12 1731
不思量自难忘°
不思量自难忘° 2020-11-29 11:09

My laravel eloquent is like this :

$products = Product::where(\'status\', 1)
            ->where(\'stock\', \'>\', 0)
            ->where(\'category         


        
12条回答
  •  醉话见心
    2020-11-29 11:34

    I solved this problem by adding the "modes" option and setting only the modes I want to be enabled in config => database.php

    'mysql' => [
        ...
        'modes' => [
            'STRICT_ALL_TABLES',
            'ERROR_FOR_DIVISION_BY_ZERO',
            'NO_ZERO_DATE',
            'NO_ZERO_IN_DATE',
            'NO_AUTO_CREATE_USER',
        ],
    ],
    

    See more details in this tutorial

提交回复
热议问题