gpt4 book ai didi

symfony - Doctrine2 两个表之间没有定义关联的innerJoin

转载 作者:行者123 更新时间:2023-12-02 10:13:30 24 4
gpt4 key购买 nike

我正在尝试加入一个在我的配置文件中没有定义关联的表。为什么?因为我不想污染这个实体(部分),因为许多其他实体可以通过“多对一”关系与该实体相关。因此,我仅在一侧定义关系,因此它不会污染我的部分实体。

我想做的是:

// 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('Company\Backend\FaqBundle\Entity\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 之外,还有其他方法吗?

最佳答案

没有。 Doctrine Query Language 需要您按照您想要使用它的方向定义关系...

关于symfony - Doctrine2 两个表之间没有定义关联的innerJoin,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9585871/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com