【发布时间】:2011-04-26 19:19:51
【问题描述】:
我在 mysql 中有一个表,我想用 CGridView 小部件显示它。到目前为止,这是我的代码:
我的控制器文件(当然是剪掉的):
public function actionIndex()
{
//call the AR table model
$model = new ViewResults();
//This generates a simple "SELECT * FROM table statment".
$list = $model->findAll();
$this->render('index', array('list'=>$list));
}
我的视图文件看起来像(截图):
<?php $this->widget('zii.widgets.grid.CGridView', array(
'dataProvider'=>$list,
)); ?>
我收到以下错误:
在 C:\xampp\framework\zii\widgets\CBaseListView.php 第 105 行调用非对象的成员函数 getData()
这是CBaseListView.php文件的源代码。
我很确定我把列表对象放在小部件中搞砸了。在将 $list 传递给小部件之前,我需要对它做些什么吗?
【问题讨论】:
标签: php mysql yii yii-components zii-widgets