gpt4 book ai didi

php - 在 Doctrine 中使用 DQL 访问多对多中间表中的字段

转载 作者:可可西里 更新时间:2023-10-31 23:50:40 25 4
gpt4 key购买 nike

我有一个名为 ContentGroup 的模型和另一个名为 Content 的模型,它们之间存在多对多关系。

中间表有一个名为 Position 的字段,当我尝试编写 DQL 查询以获取与 ContentGroup 关联的所有内容时,我无法使用涉及的模型或关系的别名引用位置字段。

有人试试这个吗?

谢谢!

最佳答案

考虑中间模型 IntModel

没有测试,但这应该有效:

$q = Doctrine::getTable('IntModel')->createQuery('p')
->leftJoin('p.Content as c')
->leftJoin('p.ContentGroup as cg')
->where('cg.id = ?', $my_content_group_id)->fetchOne();
echo $q->getPosition();

关于php - 在 Doctrine 中使用 DQL 访问多对多中间表中的字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2114097/

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