Error: Call to undefined function SUM()
Error: Call to undefined function SUM()
使用 cakephp 2
$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)
周围添加引号。
这是另一个解决方案。
$this->order->virtualFields['total_vat']='SUM(order.vat)';
$total = $this->order->find('all',array(
'fields'=>array('total_vat'),
'conditions'=>$condition
));
使用 cakephp 2
$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)
周围添加引号。
这是另一个解决方案。
$this->order->virtualFields['total_vat']='SUM(order.vat)';
$total = $this->order->find('all',array(
'fields'=>array('total_vat'),
'conditions'=>$condition
));