Home > PHP Framework > YII > body text

What to do if yii2 save fails?

藏色散人
Release: 2020-07-20 09:17:24
Original
3590 people have browsed it

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()".

What to do if yii2 save fails?

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()
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template