开发者

select SUM in Cake

开发者 https://www.devze.com 2022-12-26 20:24 出处:网络
When I tried using follow code to get the sum of the column named Serviceinfo.services $conditions = array(\'fields\'=>array(\'SUM(Serviceinfo.services) a开发者_运维问答s servicecount\'),\'conditi

When I tried using follow code to get the sum of the column named Serviceinfo.services

$conditions = array('fields'=>array('SUM(Serviceinfo.services) a开发者_运维问答s 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!


Try it as:

'SUM(Serviceinfo.services) as Serviceinfo.servicecount'
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号