Doctrine query syntax error in multiple join

半腔热情 提交于 2019-12-13 06:01:46

问题


I'm trying to query the model in my Symfony2 project, and I have a little problem that I can't figure out. Check this out:

$q2 = 
  'SELECT 
    p.code, 
    p.desc, 
    SUM(d.quantity) as quantity, 
    SUM(d.quantity*d.prize) as euros
  FROM 
    Product p 
  JOIN 
    TransactionDetail d
  JOIN 
    d.transaction t
  WHERE 
    d.product IN :array 
  AND 
    t.shop = :shop
  GROUP BY 
    p.code';
$query2 = $this->em->createQuery($q2)
  ->setParameter('shop', $shop)->setParameter('array', $array);
$result = $query2->getResult();

And I get this error:

[Syntax Error] line 0, col 248: Error: Expected =, <, <=, <>, >, >=, !=, got 't'

I don't understand it. Can anyone help me here?

Thanks.


回答1:


I think you should link TransactionDetail with another entity :

Currently :

JOIN 
    TransactionDetail d

Should be:

JOIN 
    p.transactionDetail d


来源:https://stackoverflow.com/questions/17360908/doctrine-query-syntax-error-in-multiple-join

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!