Copy CodeThe code is as follows:
Class Formmodel extends Model {
Automatic Validation settings
/*
* One: Automatic verification
The definition of automatic validation is this: Array (field,rule,message,condition,type,when,params)
Field: Represents the domain 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 news prompt;
Condition: Represents a validation condition
The value of it:
Self::must_validate indicates that 1 must be verified
Self::value_vailidate indicates that it is not empty when validating 2
self::exists_vailidate field validation for form presence (default) 0
Type: Represents the validation type
The value of it:
function (callback) means that the functions in the call to a model are validated
Confirm to verify that two fields are the same
In is within an array range
Equal verify that a value is equal to
Unique verifies that a value is unique
Regex uses regular expressions (default)
When: represents whether validation is required
The value of it:
Self::insert_status when the add operation is validated
Self::update_status when the UPDATE operation is verified
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 be verified
Array (' email ', ' email ', ' email ' format Error! ', 2),//Not for null-time verification
Array (' content ', ' require ', ' contents must '),
Array (' title ', ' ', ' title already exists ', 0, ' unique ', Self::model_insert),
);
Auto-fill settings
Array (fill field, fill content, fill condition, attach rule)
/* Fill conditions include:
Add new data when processing (default) self::model_insert add operation when filling
Update data is processed when the Self::model_update udate operation is filled
All cases are handled self::model_both (needless to say)
Additional rules include:
function usage Functions
Callback callback method
Field fills with other fields
String strings (default mode)
*/
Protected $_auto = Array (
Array (' status ', ' 1 ', Self::model_insert),
Array (' Create_time ', ' time ', Self::model_insert, ' function '),
);
}
?>
http://www.bkjia.com/PHPjc/325132.html www.bkjia.com true http://www.bkjia.com/PHPjc/325132.html techarticle Copy the code as follows:? PHP class Formmodel extends Model {//Auto-Verify Settings/*: auto-validation is defined as the definition of automatic validation: array (field,rule,message,condition. .