select SUM in Cake
Posted
by SpawnCxy
on Stack Overflow
See other posts from Stack Overflow
or by SpawnCxy
Published on 2010-04-16T03:29:06Z
Indexed on
2010/04/16
3:33 UTC
Read the original article
Hit count: 347
When I tried using follow code to get the sum of the column named Serviceinfo.services
$conditions = array('fields'=>array('SUM(Serviceinfo.services) as servicecount'),'conditions'=>array('time_id BETWEEN ? AND ?'=>array($startid,$endtid)));
$services = $this->Serviceinfo->find('all',$conditions);
I had to fetch the sum data with services[0][0]['servicecount']
which seems a little weird.And What I expect is services['Serviceinfo']['servicecount']
,or more simple one.Then how can I fix this?Thanks in advance!
© Stack Overflow or respective owner