You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When you do Model::query() I would like a way to set an alias, this works fine when you're using it like in the docs but if you include something like a ->leftJoin() you'll start to run into issues
Phalcon\Mvc\Model\Exception
The column 'account_id' is ambiguous
and because there doesn't seem to be a way to create an alias you need to do something like this
It would be nice if there was a ->alias() option or an additional param in ::query(alias: 'model') to be able to rename this instead of needing to do the full class name.
Sorry, I should have been more clear, I don't want to alias the join since that already can already be done. I want to alias the model that the ::query() is called on.
Well anyway, I suggest using the query builder instead, and you will be able to set aliases as you want. Although I do agree that having an alias into the model::query() method would be nice and possibly quite simple if recall the code correctly, but we're so close to v6 and phql is the one pending that I'm reluctant to adding new feature to the existing code base at this time.
@niden perhaps we can push this to v6 and leave it for later to implement as a new feature?
Activity
raicabogdan commentedon Sep 4, 2025
The builder join methods should already accept aliases in the last argument. Can you provide a full query example you are using?
ALameLlama commentedon Sep 4, 2025
Sorry, I should have been more clear, I don't want to alias the join since that already can already be done. I want to alias the model that the ::query() is called on.
raicabogdan commentedon Sep 8, 2025
Well anyway, I suggest using the query builder instead, and you will be able to set aliases as you want. Although I do agree that having an alias into the model::query() method would be nice and possibly quite simple if recall the code correctly, but we're so close to v6 and phql is the one pending that I'm reluctant to adding new feature to the existing code base at this time.
@niden perhaps we can push this to v6 and leave it for later to implement as a new feature?
[-][NFR]: Criteria Support for aliases[/-][+][NFR]: `Criteria` class support for aliases[/+][-][NFR]: `Criteria` class support for aliases[/-][+][NFR]: `Criteria` support for aliases[/+]ALameLlama commentedon Sep 8, 2025
@raicabogdan There is a better example and yes we could use the query builder, it would just be nice to be able to use ::query() on the model
niden commentedon Jul 5, 2026
This will require interface changes. Porting to v7