Symfony 预期已知函数,got';MD5和x27;
我需要进行如下搜索:Symfony 预期已知函数,got';MD5和x27;,symfony,doctrine-orm,Symfony,Doctrine Orm,我需要进行如下搜索: //Project\MyBundle\Repository $query = $this->getEntityManager()->getRepository('ProjectMyBundle:Product')->createQueryBuilder('p') ->where('MD5(p.id) = :id') ->setParameter('id', $id ) ->getQuery
//Project\MyBundle\Repository
$query = $this->getEntityManager()->getRepository('ProjectMyBundle:Product')->createQueryBuilder('p')
->where('MD5(p.id) = :id')
->setParameter('id', $id )
->getQuery()
->getSingleResult();
我在MD5上获取id,并且必须在数据库中搜索MD5上的id
当我进行搜索时,我出现了,给出了以下错误:
[语法错误]第0行第51列:错误:应为已知函数,获得“MD5”
表明lib:
但是我已经把它放在文件夹里了,现在我需要知道它应该放在哪里
我正在使用MySQL,Symfony 2.1.6中的条令2.2。您需要将MD5注册为自定义DQL函数:
# app/config/config.yml
doctrine:
orm:
# ...
entity_managers:
default:
# ...
dql:
string_functions:
MD5: Acme\HelloBundle\DQL\MD5Function
有关更多信息,请参阅:您使用的是哪种DBS?我使用的是Mysql,Symfony 2.1.6中的条令2.2