php - Use PostgreSQL NOT SIMILAR TO in Symfony Doctrine query builder -
i attempting use postgresql's not similar to exclude blacklist results of query,
when run query in repository method below:
$qb = $this->getentitymanager()->createquerybuilder('p'); $query = $qb ->select('p') ->from('crmpiccobundle:person', 'p') ->where("lower(p.email) not similar '(" . implode('|', $blacklist) . ")%'") ->getquery(); return $query->getresult();
i following error:
[doctrine\orm\query\queryexception] select p crmpiccobundle:person p lower(p.email) not similar '(abuse@|admin@|billing@|compliance@|devnull@)%' [doctrine\orm\query\queryexception] [syntax error] line 0, col 94: error: expected end of string, got 'to'
however, when run query against local db pgadmin works.
how can achieve doctrine using symfony doctrine query builder (or similar)? using postgresql 9.5.5
$qb = $this->getentitymanager()->createquerybuilder('p'); $select = $qb ->select('p') ->from('crmpiccobundle:person', 'p') ; foreach ($blacklist $key => $item) { $select ->where('lower(p.email) not :key'.$key) ->setparameter('key'.$key, "$item%") ; } $query = $select->getquery(); return $query->getresult();
Comments
Post a Comment