-
-
Notifications
You must be signed in to change notification settings - Fork 29
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
Bulk update [FR] #43
Comments
Is it supported by PostgreSQL, MSSQL, Oracle and SQLite? |
@samdark Yes, but a slightly different syntax. We can create multiple |
Then it is doable and is usable. No objections having it. |
Instead creating a new method "bulkUpdate" that also does not include support to update other fieds, what do you think to extend existent updateAll method? Now we have: Customer::updateAll(['status' => 1], 'status = 2'); It would be intuitive to have: Customer::updateAll([
'status' => 1,
[ 'case', [ 'id = 1' => 'value1', 'id = 2' => 'value2'], 'myfield' ]
], 'status = 2'); and I'd explicit case condition instead working on a specific matching field (in this case id). |
AFAIK you can use expression as field value in Customer::updateAll(['myfield' => new CaseExpression(/* ... */)], ['id' => [1, 2]]); |
@rob006 Well, maybe this will be the solution, but I see the last message in that topic dated 2018... When can we expect the implementation of this feature? |
@i-panov forever till someone will find it important enough and contribute it. |
MySQL has this syntax for bulk updating records:
I would like the framework to have a wrapper for this.
Something like that:
MyModel::bulkUpdate($updateField, $conditionField, $conditionValues)
.And use:
MyModel::bulkUpdate('myfield', 'id', [1 => 'value1', 2 => 'value2'])
.Sample implementation:
The text was updated successfully, but these errors were encountered: