Copy the code The code is as follows:
class FormModel extends Model {
// Automatic verification settings
/*
* 1: Automatic verification
The definition of automatic verification is as follows: array(field , rule, message, condition, type, when, params)
field: represents the field name of the database;
rule: represents the rule;
Its value depends on the type of type;
If it is condition, it is function (callback ), rule is a function name
condition is in, rule is an array
message: represents a message prompt;
condition: represents a verification condition
its value:
self::MUST_VALIDATE means must verify 1
self::VALUE_VAILIDATE Indicates verification when it is not empty
self::EXISTS_VAILIDATE Indicates the field validation of the form's existence (default) 0
type: represents the verification type
Its value:
function(callback) means that the verification is to call a function in the Model
confirm means to verify whether two fields are the same
in whether it is within a certain array range
equal to verify whether it is equal to a certain value
unique to verify whether a certain value is unique
regex uses regular expressions (default)
when: represents whether it is required Perform verification
Its value:
self::INSERT_STATUS Verify during add operation
self::UPDATE_STATUS Verify during update operation
self::ALL_STATUS (Needless to say)
params: parameters (I don’t know what they are yet) Clear)
* */
protected $_validate = array(
array('title','require','Title must!',1),//Must be verified
array('email','email','Email Format error! ',2),//Verify when it is not empty
array('content','require','Content must be'),
array('title','','Title already exists',0, 'unique',self::MODEL_INSERT),
);
//Auto-fill settings
//array (fill fields, fill content, fill conditions, additional rules)
/* Fill conditions include:
ADD when adding new data Processing (default method) self::MODEL_INSERT is filled in during add operation
Update is processed when updating data self::MODEL_UPDATE is filled in during udate operation
ALL Processed in all cases self::MODEL_BOTH (Needless to say)
Additional rules Includes:
function uses function
callback method
field fills
string with other fields (default method)
*/
protected $_auto = array(
array('status','1',self::MODEL_INSERT) ,
array('create_time','time',self::MODEL_INSERT,'function'),
);
}
?>
The above introduces the PHP tp verification form and auto-fill function code for full-face fat filling, including the content of full-face fat filling. I hope it will be helpful to friends who are interested in PHP tutorials.