php - Doctrine Extensions REGEXP not working in Symfony2 -
i using doctrine 2.1 , need use regexp in mysql.
regexp not supported in default installation of doctrine using beberlei/doctrineextensions
i cannot doctrine recognize regexp, have followed example on so.
i'm using doctrine 2.1 , symfony 2.7.1
here's code, ideas?
config
# config.yml # doctrine configuration doctrine: dbal: driver: "%database_driver%" host: "%database_host%" port: "%database_port%" dbname: "%database_name%" user: "%database_user%" password: "%database_password%" charset: utf8 keep_slave: true slaves: %database_slaves% orm: auto_generate_proxy_classes: "%kernel.debug%" auto_mapping: true metadata_cache_driver: apc query_cache_driver: apc result_cache_driver: type: service id: cache dql: string_functions: regexp: doctrineextensions\query\mysql\regexp
repository
// grouprepository $dql = "select g {$this->_entityname} g g.name regexp '^[:alpha:]'"; return $this->getentitymanager()->createquery($dql)->getresult();
error on page load
// error critical - uncaught php exception doctrine\orm\query\queryexception: "[syntax error] line 0, col 64: error: expected =, <, <=, <>, >, >=, !=, got 'regexp'" @ /symfony/vendor/doctrine/orm/lib/doctrine/orm/query/queryexception.php line 52
update:
i've updated query match expected format
$dql = "select g {$this->_entityname} g regexp(g.name, '^[:alpha:]')";
now have started getting new error:
[syntax error] line 0, col -1: error: expected =, <, <=, <>, >, >=, !=, got end of string.
i found solution through github page project
doctrine requires clauses require comparison operator though clause regexp doesn't require it.
$dql = "select g {$this->_entityname} g g.status = 1 , regexp(g.name, '^[^[:alpha:]]') = 1";
also regex character class incorrect in original question.
Comments
Post a Comment