Home > PHP Framework > YII > What to do if yii2 save fails?

What to do if yii2 save fails?

藏色散人
Release: 2020-07-20 09:17:24
Original
3705 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

1

2

3

4

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:
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
Latest Issues
yii2 error connecting to mongodb3.2.4
From 1970-01-01 08:00:00
0
0
0
How to use mongodb to do rbac in yii2
From 1970-01-01 08:00:00
0
0
0
php - yii2-ueditor-widget
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template