Copy Code code as follows:
<?php
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 name of a database;
Rule: The representative is the rules;
Its value depends on the type;
If the condition is a function (callback), rule is a function name
Condition is In,rule is an array
Message: The representative is a news hint;
Condition: Represents a validation condition
Its value:
Self::must_validate says you must verify 1
Self::value_vailidate 2 When the expression is not empty
Self::exists_vailidate indicates that the form exists with field validation (default) 0
Type: Represents the validation type
Its value:
The function (callback) indicates that the validation is a call to the functions in model
Confirm to verify that two fields are the same
In whether or not within an array range
Equal verification is 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 add operation when validation
Validation when Self::update_status UPDATE operation
Self::all_status (needless to say)
Params: parameters (Specific What I'm not sure yet)
* */
Protected $_validate = Array (
Array (' title ', ' Require ', ' title must be! ', 1,//must verify
Array (' email ', ' email ', ' mailbox format error!) ', 2,//NOT NULL-time validation
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
When update data is processed, the Self::model_update udate operation is populated
All cases are processed self::model_both (needless to say)
Additional rules include:
function using Functions
Callback callback method
Field fills with other fields
String string (default method)
*/
Protected $_auto = Array (
Array (' status ', ' 1 ', Self::model_insert),
Array (' Create_time ', ' time ', Self::model_insert, ' function '),
);
}
?>