V
V
Vladislav2018-07-02 21:28:06
Laravel
Vladislav, 2018-07-02 21:28:06

How to write this query in Laravel?

How can a given UPDATE `logs` SET `status`= 1 WHERE `status` = 0 LIMIT 1 query be written to Laravel using a DB facade?
Tried like this DB::table('logs')
->where('status', 0)
->update(['status'=>1])
->first();
But as I understand it, update already returns data and first gets a value with which it cannot work.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kairat Ubukulov, 2018-08-10
@ubukulov

DB::update("UPDATE `logs` SET `status`= 1 WHERE `status` = 0 LIMIT 1")

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question