Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Using alias on criteria models

I'm using like that \Phalcon\Models\Users.id

    Users::query()->columns('\Phalcon\Models\Users.id as id');

How can i use with alias like that u.id

    Users::query()->columns('u.id as id');

Thanks



99.6k
Accepted
answer
edited May '16

There is now way tou use alias. Criteria is mostly for selecting within model, it means it's not builded for selecting same column name from two models, if you need this behaviour use modelsManager. If you just need to select column id form users then just use :

Users::query()->columns('id');

There is now way tou use alias. Criteria is mostly for selecting within model, it means it's not builded for selecting same column name from two models, if you need this behaviour use modelsManager. If you just need to select column id form users then just use :

``` Users::query()->columns('id'); ```

id was just an example. I know that can be use alias in modelsManager. But i was wonder that using in criteria. Thanks.