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

Model alias in Criteria?

Hi there,

Is it possible to set an alias for the Model when using Mvc\Model\Criteria? I find myself using Query Builder over Criteria, as I can use an alias there (otherwise I get these huge Join lines, having to repeat the model's namespace every time..)

I do prefer to use Criteraia however, seems to be a bit more elegant solution for what I'm trying to do.

(Is there a performance difference between the two btw?) (I tend to have quite a lot of queries using Left Joins..)



98.9k
edited Oct '14

Is it possible to set an alias for the Model when using Mvc\Model\Criteria?

No, it's not possible, it's designed to create queries in an object-oriented manner over a single model.

Regarding performance, the language or the framework most of time will never be a performance bottleneck, just use the one you feel more comfortable to work with.



8.1k

Thanks!

"No, it's not possible, it's designed to create queries in an object-oriented manner over a single model."

I see/understand. IMO it could be something 'handy' - it would prevent me from repeating myself, writing out the complete model name including the namespace it's in every time.. (So, when using Query Builder I only use ->addFrom(), and not ->from() so I can use an alias :-))