A
A
Artem00712018-07-19 19:03:08
Laravel
Artem0071, 2018-07-19 19:03:08

Is it correct to insert data like this?

You need to change the current data in the line
. I do this:

$this->update([
                'total_rates' => DB::raw('total_rates + 1'), // тут еще ладно
                'rate_total' => DB::raw('rate_total + ' . $total) // а вот тут у меня вопрос
            ]);

It is necessary to change the data relative to the current data.
I found this method, but will there be any problems with any injections?
But I did not find anything suitable for this problem, and everyone everywhere advises using this particular method
. So, do you leave it like that or do you need to do something differently?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Aksentiev, 2018-07-19
@Sanasol

RAW for exceptional cases, otherwise the whole meaning of the builder is lost then.
https://laravel.com/docs/5.6/queries#increment-and...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question