![图片上传中...]
public function addUserBasicData($username,$password,$user_type,$email,$phone,$onlyuid = '598E0CD9'){
if (empty($username)) {
$username = "用户".mt_rand();
}
$data['username'] = $username;
$data['onlyuid'] = $onlyuid;
$data['password'] = $password;
$data['user_type'] = $user_type;
$data['email'] = $email;
$data['phone'] = $phone;
$data['regdate'] = NOW_TIME;
$rules = array(
array('onlyuid','','身份重复',0,'unique',1),
array('phone','require','手机号码非法','/^(13|14|15|16|17|18)d{9}$$/'),
array('phone','','您输入手机号码已经被注册!',0,'unique',1),
array('email','','您输入电子邮箱已经被注册!',0,'unique',1),
array('password','require','您尚未填写密码!'),
array('user_type','require','您尚未选择用户类型!'),
array('repassword','password','确认密码不正确',0,'confirm'),
array('password','checkPwd','密码格式不正确',0,'function'),
);
if (!$this->table('yy_common_member')->validate($rules)->create()){
$return_value["status"] = "failed";
$return_value["status_code"] = 40000;
$return_value["status_message"] = $this->getError();;
$return_value["data"]= "";
return $return_value;
}else{
$uid = $this->table('yy_common_member')->add($data);
$data2['uid'] = $uid;
$return_value["status"] = "success";
$return_value["status_code"] = 20105;
$return_value["status_message"] = "";
$return_value["data"]= $this->table('yy_common_member_profile')->add($data2);
return $return_value;
}
}
以上是代码片段
分别设置了
array('onlyuid','','身份重复',0,'unique',1), 和 array('phone','','您输入手机号码已经被注册!',0,'unique',1),
的验证规则。
但前者不生效,后者可以使用
报错
正常