I have two tables : Place
and Description
A place can contains 0, 1 or more descriptions.
So in Place entity, I have a descriptions field:
/**
* @ORM\OneToMany(targetEntity="Description", mappedBy="place")
*/
private $descriptions;
And in Description entity I have a place field:
/**
* @ORM\ManyToOne(targetEntity="Place", inversedBy="descriptions")
*/
private $place;
I would like to use the QueryBuilder to get descriptions based on a Place's field. Something like
SELECT * FROM Description WHERE Place.id = 439483
I guess I should use join, but it also returns Places column. How could I just get descriptions based on a Place condition?
Thanks
EDIT: Here is what I tried:
$em = $this->getEntityManager();
$placeRepository = $em->getRepository("AppBundle:Place");
$q = $placeRepository->createQueryBuilder('p')
->select("d")
->innerJoin("p.descriptions", "d")
->where("p.id = 439483");
$q = $q->getQuery();
$res = $q->getResult();
return $res;
But it returns a place and descriptions, I just want descriptions.