<?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