C
C
chincharovpc2019-05-01 02:03:17
Laravel
chincharovpc, 2019-05-01 02:03:17

Increase laravel mysql field value?

DB::table('table')
    ->where('id', $id)
    ->update([
        'count' => \DB::raw('count + ?'),
        'updated_at' => now()
    ]);

If instead of ? set to 1, then everything works
. And I need to increase the field by $count.
What to write instead? ?
If so, then it doesn't work.
'count' => \DB::raw('count + ?', array($count)),

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Aksentiev, 2019-05-01
@chincharovpc

https://laravel.com/docs/5.8/queries#increment-and...
in general, everything that can be mixed together.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question