控制器:
<?php
$dataProvider=new CActiveDataProvider('ClubMember', array(
'criteria'=>array(
'select'=>'Count(`fb_user_id`) as total, YEAR(`registerdate`) as year,registerdate',
'group' =>'WEEK(`registerdate`), YEAR(`registerdate`)',
'order' =>'registerdate DESC',
'condition'=>"t.club_id = '$club'",
),
'pagination'=>array(
'pageSize'=>10,
),
));
?>
查看页面:
<?php $this->widget('zii.widgets.CListView', array(
'dataProvider'=>$dataProvider,
'itemView'=>'_dispaly',
)); ?>
查看部分页面:
<?php echo $data->year; ?>
当我尝试获取$data->year
时,我收到以下错误:
Property "ClubMember.year" is not defined.
如何从上面访问“年份”属性?
答案 0 :(得分:2)
在您的课程中,您必须将它们添加为公共属性
class ClubMember extends CActiveRecord
{
public $year;
public $total;
....
...
}