thinkphp Model Validation

Source: Internet
Author: User

<?PHPclassFormmodelextendsModel {//Automatic Validation Settings    /*     * One: auto-Verify the definition of automatic validation is this: Array (field,rule,message,condition,type,when,params) field: Represents the field name of the database; rule: The Representative is the rules;   Its value depends on the type, if condition is function (callback), rule is a function name condition is In,rule is an array                            Message: The delegate is a messaging prompt; Condition: Represents the value of the validation condition: Self::must_validate indicates that 1 must be verified Self::value_vailidate to verify that 2 self::exists_vailidate indicates the field validation of a form exists when it is not empty                            (default) 0 Type: Represents the value of the validation type: function (callback) means that the functions in the call to a model are validated                             Confirm to verify that two fields are the same in whether or not within an array range equal verify that they are equal to a value                  Unique verifies that a value is unique Regex uses regular expressions (default) When: represents whether validation is required Its value: self::insert_status when the add operation validates the Self::update_status UPDATE operation                       Certificate Self::all_status (needless to say) params: parameters (Specific What I'm not sure yet) *  */    protected $_validate=Array(        Array(' title ', ' Require ', ' title must! ', 1),//must verify        Array(' email ', ' email ', ' email ' format is wrong! ', 2),//no null-time validation        Array(' content ', ' require ', ' contents must '),Array(' title ', ' ', ' title already exists ', 0, ' unique ', Self::model_insert),        ); //AutoFill Settings//array (fill field, fill content, fill condition, attach rule)    /*fill conditions include: Add new data when processing (the default) self::model_insert add operation when the update updated data when populating the processing self::model_update udate operation Time to populate all of the cases to be processed self::model_both (needless to say) Additional rules include: function using Functions callback callback method field fill s with other fields Tring string (default mode)*/    protected $_auto=Array(        Array(' Status ', ' 1 ', Self::model_insert),Array(' Create_time ', ' time ', Self::model_insert, ' function '),        );}?>

thinkphp Model Validation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.