2012-03-06 48 views
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?

回答

3

号码学说查询语言需要你定义你想使用它的方向的关系...

相关问题