nemo
(Nemoneel)
1
I can not display total number of data. I have one field, name "record", I want to display total records. Can any one help me?
This is my view file
<?php $this->widget(‘zii.widgets.grid.CGridView’, array(
'dataProvider'=>$dataProvider,
'columns'=>array(
'id',
'name',
[b]'records_id',[/b]
'note',
),
)); ?>
Controller
public function actionView()
{
$dataProvider=new CActiveDataProvider('info', array(
'criteria'=>array(
'condition'=>'User_id =' .Yii::app()->user->id,
),
'pagination'=>array(
'pageSize'=>self::PAGE_SIZE,
),
));
$this->render('view',array(
'dataProvider'=>$dataProvider,
));
}
This is my sql command
SELECT count( records_id ) FROM info WHERE records_id IS NOT NULL AND User_id = 12 GROUP BY records_id
jsoo
(Jeff)
2
echo $dataProvider->getTotalItemCount();
nemo
(Nemoneel)
3
I don’t want total records. I need SUM(records_id) field with group by . THis is my SQL command
SELECT count(records_id ) FROM info WHERE records_id IS NOT NULL AND User_id = 12 GROUP BY records_id
<?php $this->widget(‘zii.widgets.grid.CGridView’, array(
‘dataProvider’=>$dataProvider,
‘columns’=>array(
‘id’,
‘name’,
‘records_id’,
‘note’,
),
)); ?>
jsoo
(Jeff)
4
Sorry. I just can’t understand what you’re asking. 
nemo
(Nemoneel)
5
Sorry about my english. Actually I want to count record_id field if record_id IS NOT NULL
jsoo
(Jeff)
6
I think you can do this with
Info::model()->count($condition);
putting your WHERE clause into $condition, either as a string or an array to initialize a CDbCriteria.