下面我包含了一些来自我的模型和视图的代码。它告诉我 $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;