Skip to content
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

Perform operations with the fields #20

Closed
brahimbjz opened this issue May 8, 2020 · 2 comments
Closed

Perform operations with the fields #20

brahimbjz opened this issue May 8, 2020 · 2 comments

Comments

@brahimbjz
Copy link

How could an update be made of a field, whose new value is the current one + 1?
In a normal sentence it would be like this, but I don't know how to apply it to your library:

UPDATE table SET views = views + 1 WHERE id = ?

@brahimbjz
Copy link
Author

brahimbjz commented May 8, 2020

$db->increment(
    'users',
    [ 'balance' => 25 ],
    [ 'username' => 'Adam' ]
);

I found it. Sorry

@ocram
Copy link
Contributor

ocram commented May 8, 2020

No, good question, you were right, and that Database#increment method has not actually been implemented yet.

However, the thread where you probably found that method has the alternative solution as well: #13 That basic Database#exec solution works already today, and is exactly what you originally wanted, i.e. using your suggested first SQL statement with this library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants