Laravel 5.4 update all records in table without using where clause

MySQL has a safe update server mode which will not allow an update to happen unless the statement has a WHERE clause involving the primary key. If your MySQL be running in this mode, then one way to spoof it would be to use WHERE id = id, something like this:

DB::table('Currency')
        ->where('id', 'id')
        ->update(['default' => 0]);

If your MySQL server running SQL_SAFE_UPDATES mode you can use "where" like this. Or another "where clause" that includes all results.

Currency::where('id', '>', 0)->update(['default' => 0]);

Tags:

Mysql

Php

Laravel