Yii:无法在网格视图中显示数据 [英] Yii: Can not Display Data in Grid View

查看:33
本文介绍了Yii:无法在网格视图中显示数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

我收到错误:

<块引用>

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

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

我的控制器:

 公共函数 actionlist_jobseeker(){$session_id=Yii::app()->session['user_id'];如果 ($session_id == ""){$this->redirect( array('/employee/site/login'));}$user_id =$session_id;$items = Yii::app()->db->createCommand()-> 选择('*')->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

查看求职者

<div class="flash-success">

<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),'列' =>大批(大批('名称' =>'姓名','类型' =>'生的','价值' =>'CHtml::encode($data[*]->name)','htmlOptions' =>array('style'='width:90px;','class'='zzz'),),大批('名称' =>'电子邮件','类型' =>'生的','价值' =>'CHtml::encode($data[*]->email)','htmlOptions' =>array('style'='width:250px;','class'='zzz')),大批('名称' =>'密码','类型' =>'生的','价值' =>'CHtml::encode($data[*]->password)','htmlOptions' =>array('style'='width:90px;','class'='zzz')),大批('名称' =>'联系方式','类型' =>'生的','价值' =>'CHtml::encode($data[*]->contact_no)','htmlOptions' =>array('style'='width:40px;','class'='zzz')),大批('名称' =>'性别','类型' =>'生的','价值' =>'CHtml::encode($data[*]->gender)','htmlOptions' =>array('style'='width:40px;','class'='zzz')),大批('class' =>'CButtonColumn','deleteConfirmation'=>'您确定要删除此项目吗?','模板'=>'{更新}{删除}','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>

解决方案

更改所有 [*]

 $data[*]->name

匹配列

$data["name"]

I can't list data in grid using yii framework. My controller is Sitecontroller.php, My view is list_jobseeker.php.

I got the error:

Parse error: syntax error, unexpected '*', expecting ']' in C:\wamp\www\yii_new\framework\base\CComponent.php(612) : eval()'d code on line 1

Anybody give any suggestion to correct these issue?

My controller:

 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));
}

My view page - 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>

解决方案

change all the [*]

 $data[*]->name

to match columns

$data["name"]

这篇关于Yii:无法在网格视图中显示数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆