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

Bug - REGEXP MYsql Not working

I'm having a bug look like a parse on phalcon, because at the console works fine the query ! Thanks

$select = self::query(); $select->where("chave REGEXP('^_')"); return $select->execute();

Error:

Phalcon\Mvc\Model\Exception: Syntax error, unexpected token IDENTIFIER(REGEXP), near to '('^')', when parsing: SELECT [Apps\Models\ConteudosMeta].* FROM [Apps\Models\ConteudosMeta] WHERE chave REGEXP('^') (94) /var/www/html/production/www/apps/models/ConteudosMeta.php (66)

StackTrace!

0 Phalcon\Mvc\Model\Query->parse()

1 Phalcon\Mvc\Model\Query->execute()

2 Phalcon\Mvc\Model::find(Array([di] => Object(Phalcon\Di\FactoryDefault), [conditions] => chave REGEXP('^_')))

3 Phalcon\Mvc\Model\Criteria->execute()



34.6k
Accepted
answer

REGEXP is a custom SQL extension that is not supported by PHQL. You can create a custom dialect function to support it: https://blog.phalcon.io/post/phalcon-2-0-3-released