Registration process: user input data-> submit server-> insert Database
Because ar inherits from [[yii \ base \ model], it also supports data input, verification, and other features of the model. For example, you can declare a rules method to overwrite the rules in [[yii \ base \ model: Rules () | rules; you can also assign values to Ar instances in batches. You can also call [[yii \ base \ model: Validate () | validate ()] to perform data verification.
When you call the SAVE (), insert (), update () methods, [[yii \ base \ model: Validate () | validate ()] method. If the verification fails, the data will not be saved to the database.
The following example demonstrates how to use AR to obtain/verify user input data and save them to the database:
// Create a new record $ model = new customer; if ($ model-> load (yii ::$ app-> request-> post ()) & $ model-> Save () {// [retrieve user input data ], verify and save.} // update the AR $ model = Customer: findone ($ id) with the primary key of $ id. If ($ model = NULL) {Throw new notfoundhttpexception;} if ($ model-> load (yii: $ app-> request-> post () & $ model-> Save ()) {// obtain user input data, verify and save}
Reference: https://github.com/yiisoft/yii2/blob/master/docs/guide-zh-CN/db-active-record.md#%E6%95%B0%E6%8D% AE %E8%BE%93%E5%85%A5%E4%B8%8E%E6%9C%89%E6%95%88%E6%80%A7%E9%AA%8C%E8%AF%81
Reprinted please indicate the source: http://blog.csdn.net/zhyoulun/article/details/40476689
Yii framework2.0 development tutorial (7) account registration and development