Home  >  Article  >  Backend Development  >  Yii-data model-detailed explanation of rules class validator method, yii-rules_PHP tutorial

Yii-data model-detailed explanation of rules class validator method, yii-rules_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:20:18762browse

Yii-data model - detailed explanation of rules class validator method, yii-rules

public function rules()
{
return array(
array( 'project_id, type_id, status_id, owner_id, requester_id,', 'numerical', 'integerOnly'=>true),
array('name', 'length', 'max'=>256),
array('description', 'length', 'max'=>2000),
array('create_time,create_user_id,update_user_id, update_time', 'safe'),
array('id, name, description, project_id, type_id, status_id, owner_id', 'on'=>'search'),
);
}

//required: required
array('title,content','required'),

//match: Regular expression verification
array('birthday', 'match', 'pattern'=>'%^d{4}(-|/|.)d{1,2} 1d{1,2}$%', 'allowEmpty'=>true, 'message'=>'Birthday must be in year-month-day format'),

//email: Email format verification
array('user_mail', 'email'),

//url: URL format verification
array('user', 'url'),

//unique: uniqueness verification
array('username', 'unique','caseSensitive'=>false,'className'=>'user','message'=>'username "{value}" has been registered, please replace'),
//caseSensitive defines whether case sensitivity

//compare: Consistency verification
array('repassword', 'compare', 'compareAttribute'=>'password','message'=>'The passwords entered in the two places are not consistent'),

//length: length verification

//in: Verify that this attribute value is in the list (specified by range).

//numerical: Verify that the value of this attribute is a number

//captcha: Verify that the attribute value is consistent with what is shown in the verification code
array('verifyCode','captcha'),

//type: Verify whether the type of the attribute is the type specified by type.


//file: Verify whether an attribute received a valid uploaded file


//default: attribute specifies the default value


//exist: Verify whether the attribute value exists in the database


//boolean: Verify Boolean attribute value


//date: Check whether this attribute describes a date, time or datetime


//safe: Property flag is safe for batch assignment.


//unsafe: Flags are unsafe, so they cannot be batch assigned.

Yii rules rules custom writing

yxmhero1989.blog.163.com/...61864/

How to call the model’s custom method in controller in yii

Generally, Model::model()->method name

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/867538.htmlTechArticleYii-data model - detailed explanation of rules class validator method, yii-rules public function rules() { return array( array('project_id, type_id, status_id, owner_id, requester_id,', 'numerical', 'i...
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