首页 新闻 会员 周边 捐助

查询某张表group后count统计不能成功

0
悬赏园豆:20 [已关闭问题] 关闭于 2018-01-08 09:17

代码如下:查询分组是成功的 但是统计结果都是显示为1,求解。
public function relations() {
return array(
'itemsCount' => array(self::STAT, 'AccessRecord', 'id', 'select' => 'count(id)'),
);
}

public function searchbygroup() {
$criteria = new CDbCriteria;

$criteria->select = '*, count(domain) as itemsCount';
$criteria->with = 'itemsCount'; //调用relations
$criteria->compare('id', $this->id);
...
$criteria->compare('Source', $this->Source, true);
$criteria->group = 'Domain, Province';
$criteria->order = 'itemsCount DESC';

return new CActiveDataProvider($this, array(
'criteria' => $criteria, 'pagination' => array('pageSize' => 20),
));
}

$this->widget('zii.widgets.grid.CGridView', array(
'id' => 'alarm-ip-user-url-grid',
'dataProvider' => $model->searchbygroup(),
'filter' => $model,
'columns' => array(
array(
'value' => '$data->itemsCount',
'htmlOptions' => array(
'width' => '20',
'style' => 'text-align:center',
)),
...
),
));

问题补充:

有道友知道的吗

Faith_的主页 Faith_ | 菜鸟二级 | 园豆:202
提问于:2015-10-30 16:29
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册