Home  >  Article  >  Backend Development  >  What is the difference between autovalidation and autocomplete in TP framework? ?

What is the difference between autovalidation and autocomplete in TP framework? ?

WBOY
WBOYOriginal
2016-12-01 00:57:071113browse

What is the difference between auto-validation and auto-complete in TP framework? ?

Reply content:

What is the difference between auto-validation and auto-complete in TP framework? ?

AutoValidation and AutoComplete (autoOperation), and Automatic Token Verification (autoCheckToken) are functions provided by the create method in the ThinkPHP framework.
That is to say, only when you use create to create a data object These methods will only be called when.
Among them, the difference between automatic verification (autoValidation) and automatic completion (autoOperation) is:

<code>    /**
     * 创建数据对象 但不保存到数据库
     * @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;
     }</code>

Automatic verification will determine the data. If the verification fails, the creation of the data object will be terminated, while automatic completion will automatically process the data object and will not terminate the creation of the data object.

It means literally
Automatic verification, such as a certain field must be filled in, email format, mobile phone number format, etc.
Automatic completion, such as the creation time is automatically the current time, password MD5 is automatically encrypted, etc.

Automatic verification is a series of verification rules added to the model layer when writing data to the database

Automatic completion means that when certain conditions are met, some of the fields you expect will be added to the records inserted into the database, such as update time, creation time, etc.

I think you should change and learn Chinese first

Statement:
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