S
S
suhuxa12017-09-12 11:31:06
Laravel
suhuxa1, 2017-09-12 11:31:06

How to update all records in a database using laravel eloquent (but without entering where)?

It was necessary to urgently update 1 column in all records. But in laravel, until now, I have only updated using the where clause. In this case, where is not needed, because must be updated in all records. How to be?
Thank you in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
Billy Milligan, 2017-09-12
@suhuxa1

\DB::table('tName')->update(['val' => 0]);
or

\DB::update("UPDATE `{$table}` SET `val` = ? WHERE 1", $params);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question