I have a table in mysql that I want to display with the CGridView
widget. Here is my code thus far:
My Controller file (snipped of course):
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));
}
My View file looks like(snipped):
<?php $this->widget('zii.widgets.grid.CGridView', array(
'dataProvider'=>$list,
)); ?>
I'm getting the following error:
Call to a member function getData() on a non-object in C:\xampp\framework\zii\widgets\CBaseListView.php on line 105
Here is the source code to the CBaseListView.php file.
I'm pretty sure I'm screwing up by putting the list object in the widget. Is there something I have to do to $list
before I pass it to the widget?
You can use the CActiveDataProvider Yii's Class. Something like this:
Where model is your model and columns your columns.