Php Yii使用CController::redirect()函数无法正确重定向
在我正在创建的yii站点中,我有一个带有urlPhp 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
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