使用cakephp2
$total = $this->order->find('all', array(
'fields' => array(SUM(order.vat)),
'conditions' => $condition
));
SUM
函数对我不起作用,出现错误:
Call to undefined function SUM()
最佳答案
你需要这样写,
$total = $this->order->find('all',array(
'fields'=>array('SUM(order.vat) as total_vat'),
'conditions'=>$condition
));
在 SUM(order.vat)
周围添加引号。
关于php - 错误: Call to undefined function SUM(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48636337/