How do I know what is supported by PHQL?

How does PHQL translate to the respective RDBMS? How can I know what types of functions and syntax are supported by PHQL?

I just had some trouble trying to use INTERVAL, which is somewhat standard but is invalid syntax in Phalcon.

Although if I try using a function that doesn't exist or a field that doesn't exist, Phalcon doesn't trigger any error and even returns a result! How is that possible?

// doesn't trigger any error and returns data
$result = MyModel::findFirst([
    'fieldthatdoesntexist' => '> FOOBARFUNCTION(1234)'
]);

I believe Phalcon supports everything that PDO supports, and is standard SQL syntax.



20.7k
edited Oct '15

No it doesn't, unless you use the PDO Adapter directly. If you use models it uses PHQL instead. For instance PHQL doesn't support the INTERVAL syntax you find in MySQL unless you use the incubator component.

PHQL is implemented as a parser (written in C) that translates syntax in that of the target RDBMS. It allows Phalcon to offer a unified SQL language to the developer, while internally doing all the work of translating PHQL instructions to the most optimal SQL instructions depending on the RDBMS type associated with a model.

I think there should be a list of things that PHQL supports and doesn't support.