Yii框架查询相同URL下pv,uv的总和

对于Yii框架下将同列相同的数据相加,只要在model下找到模型下的search()函数里添加 

$criteria=new CDbCriteria;
$criteria->select = 'SUM(pv) AS pv_count,SUM(uv) AS uv_count,sum(stay_time) as stay_time,id,url,area_id,addtime';
$criteria->compare('id',$this->id);
$criteria->compare('module',$this->module,true);
$criteria->compare('pv',$this->pv);
$criteria->compare('uv',$this->uv);
$criteria->compare('stay_time',$this->stay_time,true);
$criteria->compare('url',$this->url);
$criteria->compare('jump',$this->jump);
$criteria->compare('area_id',$this->area_id);
$criteria->compare('addtime',$this->addtime);
        $criteria->group = 'url';//根据url来分组
        $criteria->order = 'id asc';

你可能感兴趣的:(Yii框架查询相同URL下pv,uv的总和)