我使用Yii,在CGridView如果我以後id=
查詢字符串值中缺少更新圖標:CGridView(Yii的)
URL?r=employes/update&id=
查看
單擊更新圖標,沒有什麼是正在添加(在quwey字符串)<?php
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'employee-grid',
'dataProvider'=>$model->EmpList(),
'columns'=>array(
'employee_no',
....
'date_created',
array(
'class'=>'CButtonColumn',
'template'=>'{update} {delete}',
),
), ));
?>
什麼問題?
控制器
public function actionIndex()
{
// here is your code for this action
$model = new Emp;
// print_r ($_POST);
if(isset($_POST['Emp'])) {
..
..
$connection = Yii::app()->db2 ; //Connect with 2nd db.
..
..
$command1 = 'Insert Query' // Insert Query here
$cmd1 = $connection->createCommand($command1);
$cmd1->execute();
}
$this->render('index', array(
'model'=>$model,
'id'=>$model->extension,
));
}
public function actionUpdate($id)
{
$model=$this->loadModel($id);
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Emp']))
{
$model->attributes=$_POST['Emp'];
if($model->save())
$this->redirect(array('view','id'=>$model->emp_id));
}
$this->render('update',array(
'model'=>$model,
));
}
模型
class Emp extends DB2
{
public function getDbConnection()
{
//return self::getCCDbConnection();
return Yii::app()->dbcc;
}
..
..
..
public function ExtensionList()
{
$criteria=new CDbCriteria;
$criteria->select='emp_id,emp_type,..date_created';
$criteria->condition = "emp_type = 'USER'";
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
'pagination' => array('pageSize' => 5),
));
}
..
..
..
}
我有更新我的問題 – ungalnanban