下面我列出了我的模型和视图中的一些代码。它告诉我$ date变量不存在。我不明白为什么它不会。我正在改变它作为对象,这就是为什么一些旧代码仍然有$ data->以及为什么将其更改为$ data ['']。无论它现在告诉我$ data不存在。
这是我认为的代码。
<?php
$this->widget('bootstrap.widgets.TbGridView', array(
'type'=>'condensed',
'dataProvider'=>$gridDataProvider,
'template'=>"{items}",
'columns'=>array(
array('name'=>'id', 'header'=>'Name'),
array('name'=>'emax', 'header'=>'Employees' 'value'=>$date['id']),
/*array('name'=>'location', 'value'=>'$data->city . ", " . $data->state->name', 'header'=>'Location'),
array('name'=>'phone', 'header'=>'Phone'),
array('name'=>'website', 'header'=>'Website'),
array(
'class'=>'bootstrap.widgets.TbButtonColumn',
'htmlOptions'=>array('style'=>'width: 50px'),
'template'=>"{view}",
'buttons'=>array(
'view'=>array(
'url'=>'Yii::app()->createUrl("account/rinkdetail", array("id"=>$data->id))',
),
),
),*/
),
));
?>
这是我的模型中的代码
$sql="SELECT buyer.id, emax.max as emax, emin.min as emin, rmin.min as rmin, rmin.max as rmax, firm.name as firm, region.name as region, project.name as project
FROM buyer
LEFT JOIN buyer_target target on buyer.id=target.buyer_id
LEFT JOIN employee emax on emax.id=target.max_employee_id
LEFT JOIN employee emin on emin.id=target.min_employee_id
LEFT JOIN revenue rmax on rmax.id=target.max_revenue_id
LEFT JOIN revenue rmin on rmin.id=target.min_revenue_id
LEFT JOIN buyer_target_firm tfirm on buyer.id=tfirm.buyer_id
LEFT JOIN firm on firm.id=tfirm.firm_id
LEFT JOIN buyer_target_project tproject on buyer.id=tproject.buyer_id
LEFT JOIN project on project.id=tproject.project_id
LEFT JOIN buyer_target_region tregion on buyer.id=tregion.buyer_Id
LEFT JOIN region on region.id=tregion.region_id";
$gridDataProvider = new CSqlDataProvider($sql);
return $gridDataProvider;
答案 0 :(得分:1)
我能够弄清楚。在我上面使用的例子中,它说
'value'=>$date['id']
即使我在我的例子中有DATE,我在实际测试中使用了DATA。 它需要的实际问题是什么......
'value'=>'$data["id"]'
答案 1 :(得分:0)
替换:
array('name'=>'emax', 'header'=>'Employees' 'value'=>$date['id']),
使用:
array('name'=>'emax', 'header'=>'Employees', 'value'=>$date['id']),