Isky Isky - 1 year ago 247
PHP Question

Select distinct results using findAll in doctrine

Can I select distinct value using


I'm trying :

$province = $em->getRepository("FrontendBundle:Store")->findAll(array('distinct' => true));

But it doesn't seems to work.

Answer Source

The findall don't support this behaviour, in order to make a query on-the-fly (better in a separate repository class) you can do as follow:

/** @var  $qb  \Doctrine\ORM\QueryBuilder*/
$qb = $em->getRepository("GerlaFrontendBundle:Store")->createQueryBuilder("p");

$province = $qb->select("p")

Hope this help