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

PHQL and custom functions

Are there ways to extend the PHQL parser and register some custom function?

I mean something like that:

class MyCustomPhqlFunction
{
    public function getSql() {}
    public function parse() {}
}

$di->modelsManager->registerQueryNumericFunction('CUSTOM_FUN', 'MyCustomPhqlFunction');

$phql = "SELECT CUSTOM_FUN(p.price) price FROM Store\Products p WHERE p.status = :status:";

I not found this functional in sources. But i think this functional is very important because all RDBMS have a lot of custom functions/extensions which help decide a lot of issues and give very good performance. I know that i can use raw sql, but if we use RDBMS for fast projects then we will use a lot of custom functions and extensions, in that case, why do we need PHQL without custom functions? :)

p.s. HQL, DQL, etc have this functional and this is very cool!



98.9k

Hi Igor, there is no such functionality implemented in PHQL, I think this could be implemented in a further release, could you open an NFR on Github?