Yii cactivedataprovider计数重复记录和所有记录计数

时间:2015-12-05 05:43:29

标签: yii

$str = "hey/mate/from/outside/nothing/is/to/be/done";

$first = strtok($str, "/");
$second = strtok("/");

echo "$first/$second"; // "hey/mate"

2.txt

我希望重复记录使用blahah id你可以检查下面的图像: enter image description here

1 个答案:

答案 0 :(得分:2)

由于 我已经解决了这个问题。

  $criteria = new CDbCriteria;
    $criteria->select = '*, count(*) as total';
    $criteria->group = 't.blahah_id';
    return new CActiveDataProvider($this, array(
        'criteria' => $criteria,
    ));

查看页面:

 $this->widget('zii.widgets.grid.CGridView', array(
    'id' => 'spam-user-grid',
    'itemsCssClass' => 'table table-striped table-bordered table-hover',
    'dataProvider' => $model->search(),
    'template' => "{items}{pager}",
    'pager' => array(
        'header' => '',
    ),
    'columns' => array(
        array(
            'header' => 'Blahah',
            'type' => 'raw',
            'value' => 'ucfirst($data->ratingprofile->name)',
        //'filter' => CHtml::textField('User[name]'),
        ),
        array(
            'header' => 'Total',
            'type' => 'raw',
            'value' => '$data->total',
        ),

        ),
    )
));