R
R
root092017-01-13 19:49:22
Laravel
root09, 2017-01-13 19:49:22

Laravel mysql update to multiple lines?

How can I update several rows at once with different parameters?
View parameters: id - value
Now I go through them in a loop and get a separate query for each value:

User::where('id', 1)->update(['value' => 'abc']);
User::where('id', 2)->update(['value' => 'qwe']);

Can this be somehow combined into one?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Александр Аксентьев, 2017-01-13
@root09

Для разных моделей(по ID как у вас) никак, да и смысла нет, длина записи такая же была бы.
Только если изменение всех сразу по общим признакам и на одно значение новое: https://laravel.com/docs/5.3/eloquent#updates

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question