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',
'records_id',
'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
Page 1 of 1
count number of records
#3
Posted 12 March 2010 - 09:27 AM
jsoo, on 12 March 2010 - 08:55 AM, said:
echo $dataProvider->getTotalItemCount();
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',
),
)); ?>
#6
Posted 12 March 2010 - 12:10 PM
I think you can do this with
putting your WHERE clause into $condition, either as a string or an array to initialize a CDbCriteria.
Info::model()->count($condition);
putting your WHERE clause into $condition, either as a string or an array to initialize a CDbCriteria.
Share this topic:
Page 1 of 1

Help













