Skip to content

[NFR]: Criteria support for aliases #16807

@ALameLlama

Description

@ALameLlama

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    new feature requestPlanned Feature or New Feature Request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions