Php 积垢的错误400:Yii

Php 积垢的错误400:Yii,php,yii,Php,Yii,我在yii中更新页面时遇到错误400。我没有改变任何规则 public function accessRules() { return array( array('allow', // allow all users to perform 'index' and 'view' actions 'actions'=>array('index','view'), 'users'=>array('@'), ), array('allow', // allow authentica

我在yii中更新页面时遇到错误400。我没有改变任何规则

public function accessRules()
{
return array(
array('allow',  // allow all users to perform 'index' and 'view' actions
'actions'=>array('index','view'),
'users'=>array('@'),
    ),
array('allow', // allow authenticated user to perform 'create' and 'update' actions
'actions'=>array('create','update'),
'users'=>array('@'),
),
array('allow', // allow admin user to perform 'admin' and 'delete' actions
'actions'=>array('admin','delete'),
'users'=>array('@'),
),
array('deny',  // deny all users
'users'=>array('*'),
),
);
}


public function filters()
{
return array(
'accessControl', // perform access control for CRUD operations
'postOnly + delete', // we only allow deletion via POST request
);
}
我还启用了urlmanager中的URL格式:

'urlManager'=>array(
'urlFormat'=>'path',
'rules'=>array(
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
    '<controller:w+>/<action:w+>/<id:d+>'=>'<controller>/<action>',
     '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
     '<action>'=>'site/<action>'
        ),
    ),
我仍然得到错误400只为我的一个模块,无法找出它


我很久以前就在数据库中添加了复合主键,但没有检查CRUD的功能。我想问题在于复合键

当你拿到400时,你的URL是什么?您可能没有发送ID,因此它无法找到需要重定向的页面

您是否使用标准CRUD更新操作?还是你改变了什么?您可以尝试在保存时转储$model->id以查看它是否已发送?大概是这样的:

public function actionUpdate($id) {
    $model = $this->loadModel($id);

    // Uncomment the following line if AJAX validation is needed
    // $this->performAjaxValidation($model);

    if (isset($_POST['Model'])) {
        $model->attributes = $_POST['Model'];
        if ($model->save())
            // comment the line underneath
            // $this->redirect(array('view', 'id' => $model->id)); 
            var_dump($model->id);
            die();
    }

    $this->render('update', array(
        'model' => $model,
    ));
}

main.php中是否启用了模块?是的,这是同一件事,当我在模型中添加一个复合键时,我的CRUD停止工作-公共函数primaryKey{return array'name','email';}您的数据库中有pk吗?也许这会有帮助:是的,我的数据库中有一个pk。后来我尝试使用该函数添加复合键,但它不起作用