// 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',
);