Doctrine2 innerJoin between two tables without defined association
I'm trying to join a table that doesn't have any association defined in my config file. What for? Because I don't want to pollute this object (section), because many other entities can be associated with this with a many-to-one relationship. So, I am defining the relation from one side only, so it doesn't pollute my section object.
What I am trying to do is:
// Find all sections with this bundle linked
$query = $this->getEntityManager()->getRepository('CompanyBackendSectionBundle:Section')->createQueryBuilder('s')
->select('s', 'st')
->innerJoin('s.translations', 'st')
->innerJoin('s.sectionBundles', 'sb')
->innerJoin('Company\Backend\FaqBundle\Entity\FaqQuestion', 'fq')
->where('st.locale = :locale')
->andWhere('sb.bundle = :bundleId')
->orderBy('st.name')
->setParameters(array(
'locale' => $this->getLocale(),
'bundleId' => $bundle->getId()
));
The problem is: -> innerJoin ('Company \ Backend \ FaqBundle \ Entity \ FaqQuestion', 'fq') ", I got:
[Semantical Error] line 0, col 179 near 'fq WHERE st.locale': Error: Identification Variable Company\Backend\FaqBundle\Entity\FaqQuestion used in join path expression but was not defined before.
Is there a way to do this other than using Doctrine Native Query?
+3
source to share