Doubts Distinct with Doctrine_Query

0

I have a table in mysql and I need to return unique values from this table, but I am not able to create a function or query that suits. The SQL statement in the database would be like this and it works fine, but in Doctrine I can not do:

SELECT DISTINCT anodecorrente FROM ct_noticias WHERE categoria = 'Infanto' ORDER BY nt_id ASC

I have the class that maps the table in Doctrine to CtNoticias .

    
asked by anonymous 18.09.2015 / 16:48

1 answer

0

You have the following DQL:

$this
    ->getEntityManager()
    ->createQuery('
        SELECT DISTINCT(c.anodecorrente)
        FROM CtNoticias c
        WHERE c.categoria = :categoria')
        ORDER BY c.ntId ASC
    ->setParameter('categoria', $categoria)
    ->getResult();

You may have to update the property names for the model names of your CtNoticias class.

    
22.09.2015 / 17:38