// view 下的
$v): ?>
user_id; ?>
user_name; ?>
user_realname;?>
user_password;?>
user_sex; ?>
user_roles; ?>
user_birthday; ?>
user_relation; ?>
dep_id; ?>
user_address; ?>
user_allowed; ?>
user_createtime); ?>
user_lasttime; ?>
createUrl('/parkuser/view',array('id'=>$v->user_id)) ?>">查看
createUrl('/parkuser/update',array('id'=>$v->user_id))?>">修改
createUrl('/parkuser/delete',array('id'=>$v->user_id))?>">刪除
//問題在三個操作上邊 查看 修改都可以用 唯獨刪除不行
//delete action
class DeleteAction extends Publics{
/**
* Deletes a particular model.
* If deletion is successful, the browser will be redirected to the 'admin' page.
* @param integer $id the ID of the model to be deleted
*/
public function run(){
$this->delete();
}
public function delete(){
$id = intval($_GET['id']);
$model=ParkUser::model()->findByPk($id);
if($model===null) die("");
$model->delete();
// if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
if(!isset($_GET['ajax']))
$this->getController()->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
}
}
?>
回複討論(解決方案)
$model->delete();
的時候沒有把id傳入進去。
以前在維護網站的時候發現如果某個js傳漏了,或者錯誤都可能導致這種刪除刪不掉的情況,遇到過一次,重新傳資源
id 傳過去了 地址欄變化為:http://localhost/park/index.php?r=parkuser/delete&id=11
補充一下 controller 求牛人解決下
public function actions(){
return array(
'captcha'=>array(
'class'=>'CCaptchaAction',
'backColor'=>0xFFFFFF,
),
'page'=>array(
'class'=>'CViewAction',
),
'create'=>'application.controllers.parkuser.CreateAction',
'update'=>'application.controllers.parkuser.UpdateAction',
'view'=>'application.controllers.parkuser.ViewAction',
'index'=>'application.controllers.parkuser.IndexAction',
'admin'=>'application.controllers.parkuser.AdminAction',
'delete'=>'application.controllers.parkuser.DeleteAction',
);