0
如何以下查詢轉換成doctrine2查詢如何使用的GroupBy子句中doctrine2
with using method createQuery() or createQueryBuilder()
select customer,sum(marks) from BlogBundle:Customers group by customer
如何以下查詢轉換成doctrine2查詢如何使用的GroupBy子句中doctrine2
with using method createQuery() or createQueryBuilder()
select customer,sum(marks) from BlogBundle:Customers group by customer
$qb->select('customer', 'SUM(marks)')->from('BlogBundle:Customers', 'customer')->groupBy('customer.id');
$ QB = $ EM-> createQueryBuilder(); $ qb-> select('tra.customer','SUM(tra.points)') - > from('AdminBundle:Transactions','tra') - > groupBy('tra.customer'); $; = $ qb-> getQuery() - > getResult();這是我真正的例子,當消除這個代碼得到以下錯誤[語義錯誤]行0,列11附近'客戶,SUM(tra.points)':錯誤:無效PathExpression。必須是StateFieldPathExpression。請幫助解決這個問題 – Rakhitha
你應該' - > leftJoin('tra.points','points') - > addSelect('SUM(points.id)');' – Florian