php – 订单日期查询,语法错误
作者:互联网
我想使用以下查询来排序商店下订单的日期.我想按升序执行它们但是当我尝试测试运行时,我收到以下错误:
[Syntax Error] line 0, col 7: Error: Expected IdentificationVariable |
ScalarExpression | AggregateExpression | FunctionDeclaration |
PartialObjectExpression | “(” Subselect “)” | CaseExpression, got
‘order’
$orderSales = $this->getDoctrine()->getRepository("AppBundle:Order")->createQueryBuilder('order');
$orderSales->orderBy('order.date', 'asc');
$orderSales = $orderSales->getQuery();
$orderResult = $orderSales->getResult();
我在.twig模板中渲染orderResult
return $this->render('admin/store/sales/adminsales.html.twig', array(
'orderResult' =>$orderResult
));
解决方法:
在createQueryBuilder中使用单词顺序时出错(‘order’)
改变顺序
至
只是o例如createQueryBuilder(‘o’)
结果:
$orderSales = $this->getDoctrine()->getRepository("AppBundle:Order")->createQueryBuilder('o');
$orderSales->orderBy('o.date', 'asc');
$orderSales = $orderSales->getQuery();
$orderResult = $orderSales->getResult();
标签:php,symfony,query-builder,dql,doctrine-orm 来源: https://codeday.me/bug/20190611/1220022.html