本文整理汇总了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;
}