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

前端 未结 12 1730
不思量自难忘°
不思量自难忘° 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:44

    In folder config => database.php make sure mysql strict is false, like this

    'mysql' => [
        'driver' => 'mysql',
        'host' => env('DB_HOST', '127.0.0.1'),
        'port' => env('DB_PORT', '3306'),
        'database' => env('DB_DATABASE', 'forge'),
        'username' => env('DB_USERNAME', 'forge'),
        'password' => env('DB_PASSWORD', ''),
        'unix_socket' => env('DB_SOCKET', ''),
        'charset' => 'utf8',
        'collation' => 'utf8_general_ci',
        'prefix' => '',
        'strict' => false,
        'engine' => null,
    ],
    

    if strict is true, make it false then clear config cash by run this command in cmd

    php artisan config:clear

提交回复
热议问题