Expected known function got "MD5"

I need urgent help, I will explain what I am trying to do and then what we already have.

You need to 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 am getting ID on MD5 and have to look for ID on MD5 in the database.

When I search, I found that it has the following error:

[Syntax error] line 0, col 51: Error: expected known function received by "MD5"

It is pointed out that lib:

https://github.com/beberlei/DoctrineExtensions/blob/master/lib/DoctrineExtensions/Query/Mysql/Md5.php

But I put it in a folder and now I need to know where it matters.

I am using Mysql, Doctrine 2.2 in Symfony 2.1.6

+1


source to share


1 answer


You 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 information see http://symfony.com/doc/2.0/cookbook/doctrine/custom_dql_functions.html

+1


source







All Articles