3
我試圖加入一個沒有在我的配置文件中定義的關聯的表。爲什麼?因爲我不想污染這個實體(部分),因爲許多其他實體可以通過「多對一」關係與這個實體相關聯。所以,我只在一側定義關係,所以它不會污染我的Section實體。Doctrine2 inner在沒有關聯的兩個表之間加入定義
我試圖做的是:
// 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()
));
問題是與 「 - > innerJoin( '本公司\後端\ FaqBundle \實體\ FaqQuestion', 'FQ')」,我得到:
[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.
有沒有辦法做到這一點,而不是使用Doctrine Native Query?