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

Join with alias #5

Open
trendfischer opened this issue Jan 25, 2016 · 0 comments
Open

Join with alias #5

trendfischer opened this issue Jan 25, 2016 · 0 comments

Comments

@trendfischer
Copy link

I tried to find a way to add a "JOIN" with an alias for the table. I only found the following way to implement this:

    $query->join(new Expression('`location` AS `work`'), 'work.id', '=', 'users.work_location_id');
    $query->join(new Expression('`location` AS `home`'), 'home.id', '=', 'users.home_location_id');

Using an expression does not seem to be the intended way for this, especially as quoting is not based on the given dialect.

Would it be possible to implement a solution like this:

    $query->join(['work' => 'location'], 'work.id', '=', 'users.work_location_id');

or like the workaround I am using now (the class Alias implements the ExpressionInterface for this):

    use Dialect\MySQL\Alias;
    //...
    $query->join(new Alias('location', 'home'), 'home.id', '=', 'users.home_location_id');

Or is there an implementation, which I missed?

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

No branches or pull requests

1 participant