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()
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()
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)
.