在 Yii 框架中,如何验证电子邮件和电子邮件已存在或不检查?
如何使用 Yii 模型验证规则函数代码验证电子邮件.还有如何使用 Yii 中的模型验证规则功能检查电子邮件是否存在.
How to validate email using Yii Model validation rules function code. Also how to check email exist or not using Model validation rules function in Yii.
推荐答案
您可以如下设置模型验证
You can set your model validations as below
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
//First parameter is your field name of table which has email value
array('email', 'email','message'=>"The email isn't correct"),
array('email', 'unique','message'=>'Email already exists!'),
);
}
Yii 参考链接了解更多详情:http://www.yiiframework.com/wiki/56/
Yii Reference Link For More Detail: http://www.yiiframework.com/wiki/56/
相关文章