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

Added "update and return" to the query builder #326

Merged
merged 3 commits into from
Jan 21, 2025
Merged

Conversation

freost
Copy link
Member

@freost freost commented Jan 20, 2025

Type


Yes/No
Bugfix? No
New feature? Yes
Other? No

Additional information

Yes/No
Has backwards compatibility breaks? No
Has unit and/or integration tests? Yes

Description


You can now update columns and return the updated values in an atomic operation:

$updated = $query->where('id', '=', 1)
->updateAndReturn(
    values: ['jobs_done' => new Raw('jobs_done + 1')],
    return: ['jobs_done']
);

var_dump($updated->first()->jobs_done);

@freost freost merged commit 205169d into master Jan 21, 2025
4 checks passed
@freost freost deleted the update-and-return branch January 21, 2025 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant