What is the difference between automatic verification and auto-completion in TP framework?
Reply content:
What is the difference between automatic verification and auto-completion in TP framework?
自动验证(autoValidation)
And 自动完成(autoOperation)
, there 自动检测Token验证(autoCheckToken)
is the function provided by the Create method inside the thinkphp framework.
That is, these methods are called only when you create a data object using create.
Among them, 自动验证(autoValidation)
and 自动完成(autoOperation)
different points are:
/** * 创建数据对象 但不保存到数据库 * @access public * @param mixed $data 创建数据 * @param string $type 状态 * @return mixed */ public function create($data='',$type='') { ... ... // 数据自动验证 if(!$this->autoValidation($data,$type)) return false; ... ... // 创建完成对数据进行自动处理 $this->autoOperation($data,$type); // 赋值当前数据对象 $this->data = $data; // 返回创建的数据以供其他调用 return $data; }
Automatic validation determines the data and, if validation fails, terminates the creation of the data object, while auto-completion automatically processes the data object and does not terminate the creation of the data object.
That's literally what it means
Automatic verification, such as a field must fill in, mailbox format, cell phone number format and so on
Automatic completion, such as the creation time of the automatic current time, password MD5 automatic encryption and so on
Automatic Validation is a 数据库
series of validation rules added at the model level when writing to data
Auto-Completion is when a certain condition is met, you will be ready to add some of the fields you expect from the records inserted into the database, such as update time, creation time, etc.
I think you change to learn Chinese well first