0

I am trying to create a select query in order to make a searchable index. The problem is, whenever I select an attribute for the joined class, I only receive the first result of all possible results. I tried to implode the array, but no success so far.

Example

        $query = $em->getRepository(Person::class)->createQueryBuilder('p')
        ->Select('p.id', 'p.name')
        ->join('p.books', 'i')
        ->addSelect('i.bookname')
        ->groupBy('p.id')
        ->getQuery()->getResult();

This returns an array with for every person his/her id, name and one (the first) bookname. What I cannot figure out is how to get all booknames, seperated by a comma or such. Any ideas how to achieve this?

Dirk J. Faber
  • 4,360
  • 5
  • 20
  • 58

0 Answers0