We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

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



145.0k
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');


58.1k

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.