Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

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()



33.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.phalconphp.com/post/phalcon-2-0-3-released