Log into pgsql, run command:
$ \doS+
You will get function names corresponding to json(b) and other operators, for example #>> operator is corresponding to function json_extract_path_text
Now register selected function(s) for use in PHQL at startup/bootstrap of Your App, like this example for jsonb_exists and jsonb_contains functions:
$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])
);
}
);
$dialect->registerCustomFunction(
'jsonb_contains',
function($dialect, $expression) {
$arguments = $expression['arguments'];
return sprintf(
"jsonb_contains(%s, %s)",
$dialect->getSqlExpression($arguments[0]),
$dialect->getSqlExpression($arguments[1])
);
}
);
now you can use jsonb_exists and jsonb_contains functions inside PHQL