errors" method; 2. Check whether the return value of the overridden AR life cycle method is incorrect, with statements such as "yii\db\ActiveRecord::afterValidate()" ."/> errors" method; 2. Check whether the return value of the overridden AR life cycle method is incorrect, with statements such as "yii\db\ActiveRecord::afterValidate()" .">
Home > Article > PHP Framework > What to do if yii2 save fails?
yii2 Solution to unsuccessful save: 1. Use the "$model->errors" method; 2. Check whether the return value of the overridden AR life cycle method is incorrect, with statements such as "yii\db\ ActiveRecord::afterValidate()".
Possible reasons for yii2 save failure
1. No field rules were added in the rules method
2.Transaction
3.Scenario
Solution
1.$model->errors<br>
2. Check whether the return value of the overridden AR life cycle method is incorrect
yii\db\ActiveRecord::beforeValidate(): yii\db\ActiveRecord::afterValidate() yii\db\ActiveRecord::beforeSave() yii\db\ActiveRecord::afterSave()
Recommended: "yii Tutorial"
The above is the detailed content of What to do if yii2 save fails?. For more information, please follow other related articles on the PHP Chinese website!