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 Getter for Table Alias #18167

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dmitriy-malyar89
Copy link

@dmitriy-malyar89 dmitriy-malyar89 commented Jul 9, 2020

Adds the flexibility of using aliases.
Example Query:

public function active()
{
    return $this->andWhere(['=', "$this->alias.status", 'active']);
}

User::find()->alias('instructor')->active()->all();

Result:

SELECT * FROM user instructor WHERE instructor.status = 'active';
Q A
Is bugfix?
New feature? ✔️
Breaks BC?
Tests pass?
Fixed issues comma-separated list of tickets # fixed by the PR, if any

Adds the flexibility of using aliases.
Example Query:

public function active()
{
    return $this->andWhere(['=', "$this->alias.status", 'active']);
}

User::find()->alias('instructor')->active()->all();

Result:
SELECT * FROM user instructor WHERE instructor.status = 'active';
@dmitriy-malyar89
Copy link
Author

Этот метод позволяет более удобно использовать псевдонимы и гибко использовать их в ActiveQuery.

@samdark
Copy link
Member

samdark commented Aug 7, 2020

@yiisoft/reviewers what do you think?

@dmytro-maliar
Copy link

Will this request be accepted?

@bizley
Copy link
Member

bizley commented Oct 17, 2020

Is calling $this->alias when alias is not set before, setting alias to be default? This sounds weird. And what about calling it first and then chain-calling ->alias('something')?

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

Successfully merging this pull request may close these issues.

None yet

4 participants