Dud*_*ude 5 doctrine dql symfony
我有实体 **target,citytarget,city,cityplace,place
citytarget 和 cityplace 是连接 t&c 和 c&p 的数据透视表
我需要给定城市名称和目标 ID 的地点
我尝试了以下 DQL:
SELECT t,c,p FROM MulticatorBundle:Target t
join t.cities ct
join ct.cities c
join c.places cp
join cp.places p
where c.name like '%Stahmeln%'
Run Code Online (Sandbox Code Playgroud)
但我收到:
结果:未找到别名为“c”的实体结果的父对象。父别名是“ct”。
我不知道更多......
一个简单的 SQL 可以是:
select * from target
left join citytarget on citytarget.target_id = target.id
left join city on citytarget.city_id = city.id
left join cityplace on cityplace.city_id = city.id
left join place on cityplace.id = place.id
where target.id = 1
and city.name like \'%Stahmeln%\'
Run Code Online (Sandbox Code Playgroud)
阿德里安
你需要做
SELECT t,ct, c, cp ,p FROM MulticatorBundle:Target t
join t.cities ct
join ct.cities c
join c.places cp
join cp.places p
where c.name like '%Stahmeln%'
Run Code Online (Sandbox Code Playgroud)
希望这对您有帮助
| 归档时间: |
|
| 查看次数: |
4042 次 |
| 最近记录: |