0
如何將這個查詢轉換爲DQL:SELECT etat,count(*)AS'nombre'from commande GROUP BY etat;
SELECT etat, count(*) AS 'nombre' from commande GROUP BY etat;
如何將這個查詢轉換爲DQL:SELECT etat,count(*)AS'nombre'from commande GROUP BY etat;
SELECT etat, count(*) AS 'nombre' from commande GROUP BY etat;
請試試這個
select c,count(c.id) nombre from acmeBundle:commande c group by c.etat
如果不包括條款。 你應該有指揮實體。它將返回commande實體和計數的所有字段。您可以糾正您的需求
我想這在控制器$查詢= $這個 - > getDoctrine() - > getManager() - >的createQuery(「SELECT c.etat,計數(c.id)從CommerceBundle農佈雷:Commande c group by c.etat'); $ result = $ query-> getArrayResult();但是當我想顯示使用arrayResult的var_dump($ stat_commandes);我只得到最後一行! – smarttech 2013-05-09 13:32:47
你可以試試 - >的getResult();而不是 - > getArrayResult()。這對我有用。並請改變GROUP BY與「ID」 – Nisam 2013-05-10 06:01:19
日Thnx求助領域,現在的工作 – smarttech 2013-05-10 14:42:12