我正在尝试在我的Symfony2项目中查询模型,我有一点我无法弄清楚的问题。看看这个:
$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();
我收到了这个错误:
[Syntax Error] line 0, col 248: Error: Expected =, <, <=, <>, >, >=, !=, got 't'
我不明白。谁能在这帮助我?
感谢。
答案 0 :(得分:1)
我认为你应该将TransactionDetail与另一个实体联系起来:
目前:
JOIN
TransactionDetail d
应该是:
JOIN
p.transactionDetail d