Cakephp SUM和Group by字段不检索数据
如何从Cakephp SUM和Group by字段不检索数据,cakephp,cakephp-1.3,cakephp-1.2,Cakephp,Cakephp 1.3,Cakephp 1.2,如何从SUM(total)字段检索数据?以下代码在sum\u tot中不产生值: $bill_receipts = $this->BanquetBillMaster->find('all', array('conditions' => array('status' => 2), 'fields' => array('id', 'total',
SUM(total)
字段检索数据?以下代码在sum\u tot
中不产生值:
$bill_receipts = $this->BanquetBillMaster->find('all',
array('conditions' => array('status' => 2),
'fields' => array('id', 'total',
'(SUM(total)) AS sum_tot','booking_master_id'),
'group' => 'booking_master_id',
'contain' => false));
foreach($bill_receipts as $aa)
{
echo $aa['BanquetBillMaster']['sum_tot'];
}
尝试使用
debug($bill\u receives)打印数组代码>,总和字段可能在$aa[0]['sum\u tot']]
中。命名字段位于“正常”结构之外。您的表中有这样的字段吗?