2

控制器:

<?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.

如何从上方访问属性“年份”?

4

1 回答 1

2

在您的班级中,您必须将它们添加为公共属性

class ClubMember extends CActiveRecord
{
    public $year;
    public $total;
    ....
    ...
}
于 2013-03-07T09:22:04.803 回答