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

LEFT JOIN LATERAL in PHQL

Hello,

is there a way to do LEFT JOIN LATERAL in PHQL?

Like in this example:

https://sqlfiddle.com/#!15/06dfe/6

https://stackoverflow.com/questions/30628950/postgresql-left-outer-join-on-json-array

by using some kind of dialect extension?

I can replace "->>" by postgresql function and update dialect similar to this:

$dialect = new \Phalcon\Db\Dialect\Postgresql();
$dialect->registerCustomFunction(
    'jsonb_exists',
    function($dialect, $expression) {
        $arguments = $expression['arguments'];
        return sprintf(
            "jsonb_exists(%s, %s)",
            $dialect->getSqlExpression($arguments[0]),
            $dialect->getSqlExpression($arguments[1])
        );
    }
);

but how can I extend dialect to recognize LEFT JOIN LATERAL?



32.3k
Accepted
answer

Hi @tomasz here you have the docuentantion to extend mysql dialect and you can check some examples in incubator repo

Good luck