Select different results using findAll in the doctrine

Can I select a different value using the function findAll()?

I'm trying to:

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

But it does not work.

+4
source share
3 answers

Findall does not support this behavior, in order to make the request on the fly (better in a separate repository class), you can do the following:

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

$province = $qb->select("p")
    ->distinct(true)
    ->getQuery()
    ->getResult();

Hope for this help

+9
source
$province = $em->getRepository("FrontendBundle:Store")->findBy(array('distinct' => true));

see also http://symfony.com/doc/current/book/doctrine.html#fetching-objects-from-the-database

all the best

+1
source

findAll() , findAll() Entity Repository .

public function findAll() {
   return $this->findBy(array(), array(array('distinct' => TRUE));
}

findAll(), .

0

Source: https://habr.com/ru/post/1617458/


All Articles