phalcon / phalcon/cphalcon

[NFR]: `Criteria` support for aliases

Open
#16,807 5 comments 0 reactions 1 assignee View on GitHub

@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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.