我用createQuery()而不是queryBuilder創建查詢,但是我需要在查詢生成器中轉換查詢,以便在EntityType中生成表單。這裏是我的查詢:需要一些幫助將查詢從createQuery()轉換爲queryBuilder()
SELECT p FROM D2ECoreBundle:Player p,
D2ECoreBundle:LadderMatch lm,
D2ECoreBundle:PlayerComposition hpc
JOIN hpc.players hp,
D2ECoreBundle:PlayerComposition fpc
JOIN fpc.players fp
WHERE (lm.homePlayerComposition = hpc AND hp = p)
OR (lm.foreignPlayerComposition = fpc AND fp = p)
和這裏是我認爲這將是在QueryBuilder的,但不工作:
$qb->select('p')
->from('D2ECoreBundle:Player', 'p')
->from('D2ECoreBundle:LadderMatch', 'lm')
->from('D2ECoreBundle:PlayerComposition', 'hpc')
->join('hpc.players', 'hp')
->from('D2ECoreBundle:PlayerComposition', 'fpc')
->join('fpc.players', 'fp')
->where('lm.homePlayerComposition = hpc' AND 'hp = p')
->orwhere('lm.foreignPlayerComposition = fpc' AND 'fp = p');
有誰知道我應該改變已經工作?感謝您的答案!
玩家不包含LadderMatch,這就是問題所在。但是,我得到我的一個mystakes。梯隊比賽2球員組合(Home et Foreign)和球員組合包含球員。但我只是想要玩家! – copndz 2012-03-27 16:17:00