预期的已知功能,得到'MD5' [英] Expected known function, got 'MD5'
问题描述
我需要一个紧急帮助,我将解释我正在做什么,然后我们已经有了。
需要这样搜索:
// Project\MyBundle\Repository
$ query = $ this-> getEntityManager () - > getRepository('ProjectMyBundle:Product') - > createQueryBuilder('p')
- >其中('MD5(p.id)=:id')
- > setParameter('id',$ id)
- > getQuery()
- > getSingleResult();
我得到MD5上的ID,必须在数据库中的MD5上搜索一个id。 p>
当我进行搜索时,我出现了,给我以下错误:
[语法错误]行0,col 51:错误:预期的已知功能,得到'MD5'
表示lib: p>
但是我我把它放在文件夹中,现在我需要知道它应该在哪里。
我在Symfony 2.1.6中使用Mysql,Doctrine 2.2 $ / b $ b
您需要将MD5注册为自定义DQL函数:
#app / config / config.yml
doctrine:
orm:
#...
en tity_managers:
默认值:
#...
dql:
string_functions:
MD5:Acme\HelloBundle\DQL\MD5Function
有关详细信息,请参阅: http://symfony.com/doc/2.0/cookbook/doctrine/custom_dql_functions.html
I need an urgent help, I'll explain what I'm trying to do and then what we already have.
Need to do a search like this:
//Project\MyBundle\Repository
$query = $this->getEntityManager()->getRepository('ProjectMyBundle:Product')->createQueryBuilder('p')
->where('MD5(p.id) = :id')
->setParameter('id', $id )
->getQuery()
->getSingleResult();
I get the id on MD5 and have to search for an id on MD5 in the database.
When I do a search, I showed up, gives me the following error:
[Syntax Error] line 0, col 51: Error: Expected known function, got 'MD5'
Indicated that lib:
But I've put it inside the folder and now I need to know where it should matter.
I am using Mysql, Doctrine 2.2 in Symfony 2.1.6
You'll need to register MD5 as a custom DQL function:
# app/config/config.yml
doctrine:
orm:
# ...
entity_managers:
default:
# ...
dql:
string_functions:
MD5: Acme\HelloBundle\DQL\MD5Function
For more info, see: http://symfony.com/doc/2.0/cookbook/doctrine/custom_dql_functions.html
这篇关于预期的已知功能,得到'MD5'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!