dongxieting9623 2018-02-06 05:54
浏览 256
已采纳

错误:调用未定义的函数SUM()

using cakephp2

$total = $this->order->find('all', array(
    'fields'     => array(SUM(order.vat)),
    'conditions' => $condition
));

SUM function is not working for me, am geeting error:

Call to undefined function SUM()

  • 写回答

2条回答 默认 最新

  • douchen2025 2018-02-06 05:59
    关注

    You need to write it like this,

    $total = $this->order->find('all',array(
      'fields'=>array('SUM(order.vat) as total_vat'),
      'conditions'=>$condition
    ));
    

    Add quotes around SUM(order.vat).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?