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

SQL expressions via the Model?

Hi I've been trying to figure out how to utilize SQL expressions, for instance COALESCE() as well as any others of it's ilk , via the Model object? I've been reading the documentation but cannot find an example of such useage.



93.7k
Accepted
answer

Those are mysql only features and are not supported by phql. You have to use a dialect class. Similar question asked here: https://stackoverflow.com/questions/47972097/phalcon-datetime-in-model-query-error

Also you can search forum for similar problems and how to solve. Examples: https://forum.phalcon.io/search?q=mysql+functions

Thanks. I was afraid of that but at least there appears to be a way around it.

Those are mysql only features and are not supported by phql. You have to use a dialect class. Similar question asked here: https://stackoverflow.com/questions/47972097/phalcon-datetime-in-model-query-error

Also you can search forum for similar problems and how to solve. Examples: https://forum.phalcon.io/search?q=mysql+functions