[NFR]: `Criteria` support for aliases
Open
@niden is already working on this.
Since Jun 28, 2026.
7.0
new feature request
- Dominant language
- PHP
- Stars
- 10.8k
- Forks
- 1.9k
- Avg merge
- 7h 2m
- Merged PRs (30d)
- 47
Description
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
Model::query()
->columns($columns)
->where(sprintf('%s.account_id = :id:', Model::class), ['id' => $user->account_id])
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.
Relevant file
https://github.com/phalcon/cphalcon/blob/master/phalcon/Mvc/Model/Criteria.zep
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.