0
在我的网站中,我有两个帐户,一个是管理员,一个是用户。管理员可以编辑,创建和删除。我实现的所有这些功能工作正常,但现在当我在另一个浏览器中打开我的用户,并在另一个浏览器中从管理员执行删除功能时,它不会自动更新到用户网站。我需要在我的用户网站中手动刷新我的页面以查看当前记录。Bootstrap删除数据库中的项目
当管理员进行修改时,自动更新/自动刷新用户页面的方法是什么?
下面是我在控制器中执行删除功能的代码。请让我知道我可以调整我的代码以自动刷新用户网站中的内容。
这是访问规则
public function accessRules()
{
return array(
array('allow', // allow all users to perform 'index' and 'view' actions
'actions'=>array('index'),
'users'=>array('*'),
),
array('allow',
'actions'=>array('view','user'),
'users'=>array('@'),
),
array('allow', // allow admin user to perform 'admin' and 'delete' actions
'actions'=>array('create','update', 'admin','delete'),
'expression' => 'Yii::app()->user->isAdmin()'
),
array('deny', // deny all users
'users'=>array('*'),
),
);
}
这是删除功能
public function actionDelete($id)
{
if(Yii::app()->request->isPostRequest)
{
// we only allow deletion via POST request
$this->loadModel($id)->delete();
// if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
if(!isset($_GET['ajax']))
$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
}
else
throw new CHttpException(400,'Invalid request. Please do not repeat this request again.');
}
请检查[这里] [1]后,建议对PHP的,只是申请成为MVC风格。 [1]:http://stackoverflow.com/questions/4629642/how-can-i-refresh-a-page-when-a-database-is-updated – StreetCoder