Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Yii使用CController::redirect()函数无法正确重定向_Php_Yii - Fatal编程技术网

Php Yii使用CController::redirect()函数无法正确重定向

Php Yii使用CController::redirect()函数无法正确重定向,php,yii,Php,Yii,在我正在创建的yii站点中,我有一个带有urlhttp://localhost/administrator/restaurant/list 它以表格格式显示餐厅列表,并带有删除按钮。删除按钮指向http://localhost/administrator/restaurant/delete/ 我的控制器的actionDelete如下所示: public function actionDelete(){ $model = Restaurants::model()->findB

在我正在创建的yii站点中,我有一个带有url
http://localhost/administrator/restaurant/list
它以表格格式显示餐厅列表,并带有删除按钮。删除按钮指向
http://localhost/administrator/restaurant/delete/

我的控制器的
actionDelete
如下所示:

public function actionDelete(){
        $model = Restaurants::model()->findByAttributes(
                                        array(
                                            'id'=>$_GET['id'],
                                            'clientId'=>Yii::app()->user->clientId
                                        ));
        $model->delete();
        Yii::app()->user->setFlash('success',Yii::t('error','Restaurant has been deleted successfully'));
        $this->redirect('restaurant/list',true);
    }

但单击delete按钮后,该行将从数据库中成功删除,但不会重定向到
http://localhost/administrator/restaurant/list
页面正在重定向到
http://localhost/administrator/restaurant/delete/restaurant/list
并显示错误。我实现重定向功能的方式是否有问题?

改用数组路由:

$this->redirect(array('restaurant/list'), true);

使用GET进行删除是一个非常糟糕的主意,因为浏览器可以在您单击链接之前预取链接。对于任何类似的场景,都应该使用POST