-
-
Notifications
You must be signed in to change notification settings - Fork 36
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
Command::update() - add ability to pass Query to UPDATE FROM #94
Comments
As a result of #10287 and Gitter talk. @exru needs to make an UPDATE query from another query. Assume we have the following query: $query = new \yii\db\Query()
->select(['id', 'winr'])
->from('leaders')
->where(['state' => User::STATE_BLOCKED]);
// yeah, it's a simple one and we manage with it without the feature,
// but imagine that it's huge, with tons of joins, expressions in select, etc and we need to update another table from query. The expected SQL should be like @exru posted in the header. @exru suggests to add a chained $query->update('bet', ['status' => new Expression('subquery.winr')], 'id = subquery.id'); But I prefer to modify $queryBuilder->update(['bet', 'subquery' => $query], ['status' => new Expression('subquery.winr')], 'id = subquery.id'); or $queryBuilder->update('bet', ['status' => new Expression('subquery.winr')], 'id = subquery.id')->from(['subquery' => $query]); @yiisoft/core-developers |
I guess be appropriate the |
The text was updated successfully, but these errors were encountered: