Yii:无法在网格视图中显示数据

时间:2014-04-23 10:14:50

标签: php yii yii-extensions cgridview

我无法使用yii框架在网格中列出数据。我的控制器是Sitecontroller.php,我的视图是list_jobseeker.php

我收到了错误:

  

解析错误:语法错误,意外' *',期待']'在C:\ wamp \ www \ yii_new \ framework \ base \ CComponent.php(612):eval()' d代码在第1行

有人提出任何纠正这些问题的建议吗?

我的控制器:

 public function actionlist_jobseeker()
  {
  $session_id=Yii::app()->session['user_id']; 
  if ($session_id == "")
    {
        $this->redirect( array('/employee/site/login'));
    }
  $user_id  =$session_id;
  $items = Yii::app()->db->createCommand()
     ->select('*')
     ->from('job_seeker_profile s')
     ->join('job_profile j','s.user_id = j.user_id')
     ->order('s.id')
     ->queryAll();
     $this->render('list_jobseeker',array('items' =>$items));
}

我的观点页面 - list_jobseeker.php

<h1>View Jobseeker</h1>

<div class="flash-success">

</div>

<div class="form">
<?php
 $this->widget('zii.widgets.grid.CGridView', array(
    'id'=>'rates-phase-grid',
   'htmlOptions' => array('class' => 'table table-striped table-bordered table-hover'),
    'dataProvider'=>new CArrayDataProvider($items),
    'columns' => array(
        array(
            'name' => 'Name',
            'type' => 'raw',
            'value' => 'CHtml::encode($data[*]->name)',
            'htmlOptions' => array('style'=>'width:90px;','class'=>'zzz'),

     ),
        array(
            'name' => 'Email',
            'type' => 'raw',
            'value' => 'CHtml::encode($data[*]->email)',
            'htmlOptions' => array('style'=>'width:250px;','class'=>'zzz')

        ),
        array(
            'name' => 'Password',
            'type' => 'raw',
            'value' => 'CHtml::encode($data[*]->password)',
            'htmlOptions' => array('style'=>'width:90px;','class'=>'zzz')
        ),
        array(
            'name' => 'Contact No',
            'type' => 'raw',
            'value' => 'CHtml::encode($data[*]->contact_no)',
            'htmlOptions' => array('style'=>'width:40px;','class'=>'zzz')

        ),
         array(
            'name' => 'Gender',
            'type' => 'raw',
            'value' => 'CHtml::encode($data[*]->gender)',
            'htmlOptions' => array('style'=>'width:40px;','class'=>'zzz')

        ),


        array(
            'class' =>'CButtonColumn',
            'deleteConfirmation'=>'Are you sure you want to delte this item?',
            'template'=>'{update}{delete}',

            'buttons' =>array('update'=>array(

             'label'=>'edit',
     'url'=>'Yii::app()->controller->createUrl("UpdateJob",array("id"=>$data["id"]))',

                ),
             'delete'=>array('label'=>'delete',
     'url'=>'Yii::app()->controller->createUrl("DeleteJob",array("id"=>$data["id"]))'),

                )
            )
          ),
));
?>

</tbody>

1 个答案:

答案 0 :(得分:0)

更改所有[*]

 $data[*]->name

匹配列

$data["name"]