gpt4 book ai didi

mysql - Doctrine left join 但无法获取第二个表的字段,为什么?

转载 作者:行者123 更新时间:2023-11-29 11:40:46 25 4
gpt4 key购买 nike

例如,我有这个:

$this->createQueryBuilder('x')->select()->join('x.coupons', 'c')->getQuery()->getResult()

用户-s和他们的优惠券-s。这会连接coupons 表,但不会选择其字段。如果我引用->getCoupons(),它将进行另一个选择。有什么解决办法吗?

最佳答案

将查询生成器更改为:

$this->createQueryBuilder('x')
->select('x', 'c')
->join('x.coupons', 'c')
->getQuery()
->getResult()

关于mysql - Doctrine left join 但无法获取第二个表的字段,为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35815497/

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