Home  >  Article  >  Backend Development  >  PHP tp verification form and autofill function code_PHP tutorial

PHP tp verification form and autofill function code_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:20:24909browse

Copy 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 a rule;
its value depends on the type of type;
if condition is function (callback), rule is a function name
condition is in, rule is An array
message: represents the message prompt;
condition: represents the verification condition
Its value:
self::MUST_VALIDATE means it must be verified 1
self::VALUE_VAILIDATE means it is not empty When validating 2
self::EXISTS_VAILIDATE indicates field validation that exists in the form (default) 0
type: represents the validation type
Its value:
function(callback) indicates that the verification is to call a Model The function in
confirm means to verify whether two fields are the same
in and whether they are within a certain array range
equal to verify whether they are equal to a certain value
unique to verify whether a certain value is unique
regex Use regular expressions (default)
when: represents whether verification needs to be performed
Its value:
self::INSERT_STATUS Verification during add operation
self::UPDATE_STATUS Verification during update operation
self::ALL_STATUS (Needless to say)
params: parameters (I don’t know exactly what they are yet)
* */
protected $_validate = array(
array('title ','require','Title must be! ',1),//Must be verified
array('email','email','Email format is wrong!',2),//Verify if it is not empty
array('content','require','content must'),
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 is processed when new data is added ( Default method) self::MODEL_INSERT is filled with
during add operation. Update is processed when updating data. self::MODEL_UPDATE is filled with
ALL during udate operation. Self::MODEL_BOTH is processed in all cases (needless to say)
Additional rules include:
function uses function
callback 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'),
);
}
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/325132.htmlTechArticleCopy the code as follows: ?php class FormModel extends Model { // Automatic verification settings/* * 1: Automatic verification The definition of automatic verification is like this: array(field, rule, message, condition...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn