model->save() Not Working In Yii2

后端 未结 10 1551
情歌与酒
情歌与酒 2020-12-06 01:10

Previously, I was not using $model->save() function for inserting or updating any data. I was simply using createCommand() to execute query and

10条回答
  •  借酒劲吻你
    2020-12-06 01:58

    It could be a problem related with your validation rules.

    Try, as a test, to save the model without any validation in this way:

    $model->save(false);
    

    If the model is saved you have conflict with your validation rules. Try selectively removing your validation rule(s) to find the validation conflict.

    If you have redefined the value present in active record you don't assign the value to the var for db but for this new var and then are not save.

    Try removing the duplicated var.. (only the vars non mapped to db should be declared here.)

提交回复
热议问题