I have category table and make table. Both tables related by third category_make table creating many to many relationship.
/**
* @var \Doctrine\Common\Collections\Collection
*
* @ORM\ManyToMany(targetEntity="Ladisi\MotorsBundle\Entity\Make", inversedBy="catogory", fetch="EAGER")
* @ORM\JoinTable(name="catogory_make",
* joinColumns={
* @ORM\JoinColumn(name="catogory_id", referencedColumnName="cat_id")
* },
* inverseJoinColumns={
* @ORM\JoinColumn(name="make_id", referencedColumnName="make_id")
* }
* )
*/
private $make;
I want to get makes that belongs to particular category. I have tried,
$query = $em
->createQuery(
'SELECT c, m FROM LadisiMotorsBundle:Catagory c
JOIN c.make m
WHERE c.catId= :id'
)->setParameter('id', $id);
$result = $query->getResult();
but every time I get only category fields, make entity is not available in result. I also tried to get makes just by calling getMakes method on catagory object, it also returns null (not entity, i guess proxy). How do i solve this. Any help would be great.