本文整理匯總了PHP中School::getAbbr方法的典型用法代碼示例。如果您正苦於以下問題:PHP School::getAbbr方法的具體用法?PHP School::getAbbr怎麽用?PHP School::getAbbr使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類School
的用法示例。
在下文中一共展示了School::getAbbr方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: login
/**
* 登錄函數
* @method login
* @access private
* @author NewFuture[newfuture@yunyin.org]
* @param [string] $password [md5密碼]
* @return [bool/int] [用戶id]
*/
private function login($number, $password, $sch_id = null)
{
$conditon = ['number' => $number];
//指定學校
$sch_id and $conditon['sch_id'] = $sch_id;
$users = UserModel::where($conditon)->select('id,password,sch_id,name');
if (empty($users)) {
/*未注冊*/
return null;
} else {
/*驗證結果*/
$password = Encrypt::encryptPwd($password, $number);
$reg_schools = [];
foreach ($users as &$user) {
if ($user['password'] == $password) {
/*登錄成功*/
$user['number'] = $number;
$token = Auth::token($user);
$sessionid = Session::start();
unset($user['password']);
Session::set('user', $user);
Cookie::set('token', $token);
// $user['school'] = SchoolModel::getName($user['sch_id']);
$result = ['sid' => $sessionid, 'user' => $user, 'msg' => '登錄成功!', 'token' => $token];
$this->response(1, $result);
return true;
} else {
/*驗證失敗*/
$sid = $user['sch_id'];
$reg_schools[$sid] = School::getAbbr($sid);
}
}
$this->reg_schools = $reg_schools;
return false;
}
}
示例2: parse
private function parse(&$s)
{
/*如果是字符切成數組*/
if (is_string($s)) {
$s = explode(',', $s);
}
/*id轉成縮寫*/
if (is_numeric(end($s))) {
array_walk($s, function (&$v) {
$v = School::getAbbr($v);
});
}
return $s;
}