Hello everybody
i am trying to sort my database data by a calculated column
$dataProvider = new CActiveDataProvider('Entries', array(
'criteria'=>array(
'select' => 't.*, SUM(votes.value) AS test',
'join' => 'join votes ON votes.type_id = t.id',
'condition' => 'votes.type = 0',
'group' => 't.id',
),
'pagination'=>array('pageSize' => 30,)
));
$this->render('index',array(
'dataProvider'=>$dataProvider,
));
in the view i have this:
<?php
// $dataProvider->sort->defaultOrder='$entry->test DESC';
$data = $dataProvider->getData();
foreach ($data as $entry)
{
echo $entry->test."<br />";
}
?>
But I always get this error message and i can’t figure out why:
Property "Entries.test" is not defined although it is in my select clause.
How am I able to sort my data on a calculated column?
Any help would be greatly appreciated.