-
Notifications
You must be signed in to change notification settings - Fork 190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to sum values in update? #304
Comments
Hey @neto737, if you haven't solved this yet, what does the code above produce? I see you're also using a mixture of bound params and value inserts which isn't recommended. Try something like: $query = static::getInstance()->update('users')
->set('balance += ?', $amount)
->where('id = ?', $userId); |
Actually I tried this way, tried a lot of other ways to sum values in an update query, but nothing worked yet. Nothing worked yet. |
Fixed using Literal class $query = static::getInstance()->update('users')
->set([
'balance' => new Literal('balance + ' . $amount)
])
->where('id', $userId); |
Great to hear! I'm going to reopen this and mark as a potential bug to fix in 3.0. There should be a way to do this without forcing a |
Hi,
I'm using FluentPDO, and I haven't found anywhere how to sum a value in an update query
Like:
I tried to do this way:
But it doesn't work, is there another way to do this?
The text was updated successfully, but these errors were encountered: