function create_invite_code(){ $d = substr(base_convert(md5(uniqid(md5(microtime(true)),true)), 16, 10), 0, 6); $w['referral_code'] = array('eq', $d); $user_info = Db::name('user')->field("id")->where($w)->find(); if ($user_info) { $this->create_invite_code(); } return $d; }