Hello dear Yii community,
I have a problem I can’t figure out by myself,
I am still new to yii,
I try this query in my model
public function getSumar() {
$oDbConnection = Yii::app()->db;
$oCommand = $oDbConnection->createCommand("SELECT requester_id,
SUM(CASE WHEN type_id = 0 THEN hours ELSE 0 END) AS 'Spracovanie dopytu',
SUM(CASE WHEN type_id = 1 THEN hours ELSE 0 END) AS 'Spracovanie podkladov',
SUM(CASE WHEN type_id = 2 THEN hours ELSE 0 END) AS 'Ostatne cinnosti'
FROM `tbl_report`
GROUP BY requester_id
UNION
SELECT 'TOTAL',
SUM(CASE WHEN type_id = 0 THEN hours ELSE 0 END),
SUM(CASE WHEN type_id = 1 THEN hours ELSE 0 END),
SUM(CASE WHEN type_id = 2 THEN hours ELSE 0 END)
FROM `tbl_report`
");
$query = $oCommand->queryAll();
$dataProvider=new CSqlDataProvider($oCommand, array(
// 'keyField' => 'requester_id',
));
return $dataProvider;
}
this is in my controller
public function actionSumar()
{
$model = new DailyReport('getSumar');
$this->render('sumar',array(
'model'=>$model,
));
}
I have this code in my view
$this->widget('zii.widgets.grid.CGridView', array(
'dataProvider'=>$model->getSumar(),
));
and I get this error:
The column must be specified in the format of "Name:Type:Label", where "Type" and "Label" are optional.
The error is there because I use custom naming of columns in my query :{
but please, can anyone tell me what to do so it will accept those custom named columns?