Answer the question
In order to leave comments, you need to log in
How to get data from ManyToMany in createQueryBuilder?
$qbRows = $this
->createQueryBuilder('b')
->where('b.id = ' . (int) $id)
->select('b.id')
->addSelect('b.name')
->addSelect('b.Users')
->getQuery();
Answer the question
In order to leave comments, you need to log in
If you get not the whole entity, but only specific fields, obviously, you need to do a JOIN and access the relationship fields using the alias that you assign in the JOIN.
If you unload entities completely:
$query= $this->
->createQueryBuilder()
->select('b, users')
->from(B::class, 'b')
->join('b.users', 'users')
->where('b.id = :id')
->setParameter('id', $id)
->getQuery();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question