-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
JoinWith - assign a column aliases to an attribute of related model #12846
Comments
@minitia Please format your code properly. As for your problem, seems like it's already covered in offiical docs in Active Record - Selecting extra fields section. The given example uses one model, but instead of assigning to If you want to assign ->joinWith(['books' => function (\yii\db\ActiveQuery $query) {
$query->addSelect('distance' => 'your expression goes here']);
}] You can find more info about joinWith and addSelect in official docs. |
This is an automated comment, triggered by adding the label Please note, that the GitHub Issue Tracker is for bug reports and feature requests only. We are happy to help you on the support forum, on IRC (#yii on freenode), or Gitter. Please use one of the above mentioned resources to discuss the problem. |
Probably I have not explained well. |
@minitia I covered this with separate example. Same technique is used, the only difference is you need to move selecting distance part to |
@arogachev thank you. |
@minitia In PHP you can pass additional variables to closure using function (\yii\db\ActiveQuery $query) use ($coords) {
// Use $coords here
} |
Thanks you so much! Il 26 ott 2016 2:00 PM, "Alexey Rogachev" notifications@github.com ha
|
This is my query:
I'd like to assign distance value to
tripPoints.distance
attribute.It seems that I can assign to
Trip
attribute.Any suggestion?
Thank you,
Mattia
The text was updated successfully, but these errors were encountered: