//自动验证
protected $_validate = array(
//-1,账号长度不合法!
array('username','/^[^@]{2,20}$/i',-1,self::EXISTS_VALIDATE),//默认为正则验证
//-2,密码长度不合法!,新增模式
array('password','6,30',-2,self::EXISTS_VALIDATE,'length', self::MODEL_BOTH),
//-6,手机号不合法!
array('phone','/^(0|86|17951)?(13[0-9]|15[012356789]|18[0-9]|14[57])[0-9]{8}$/',-6,self::EXISTS_VALIDATE),
//-3,邮箱格式不正确
array('email','email',-3,self::EXISTS_VALIDATE),
//-4,账号被占用
array('username', '', -4, self::EXISTS_VALIDATE, 'unique', self::MODEL_INSERT),
//-7,手机号被占用
array('phone','',-7,self::EXISTS_VALIDATE,'unique',self::MODEL_INSERT),
//-5,邮箱被占用
array('email','',-5,self::EXISTS_VALIDATE,'unique',self::MODEL_INSERT),
);
//修改会员信息
public function update($id, $password, $phone, $email) {
//用于验证
$data = array(
'id'=>$id,
'phone'=>$phone,
'email'=>$email,
);
//$password有值时才验证
if($password){
$data['password'] = $password;
}
if($this->create($data)) {
$uid = $this->save();
return (false !== $uid) ? $uid : 0;
}else{
return $this->getError();
}
}
QQ图片20150403114023.png ( 50.26 KB 下载:73 次 )