继续检索“getByUserName”
/**
* 根据用户名获取用户信息
*
* @param string $userName
* @param bool $withMainFields 是否取用户主要信息
* @param bool $withMemberDataFields 是否取用户基本信息
* @param bool $withMemberInfoFields 是否取用户相关信息
* @return array|null 用户数据数组,找不到返回null
*/
function getByUserName($userName, $withMainFields = true, $withMemberDataFields = false, $withMemberInfoFields = false) {
$userName = trim($userName);
if (!$userName) return null;
$member = array();
$membersDb = $this->_getMembersDB();
$data = $membersDb->getUserByUserName($userName);
if (!$data || !$data['uid']) return null;
$userId = (int) $data['uid'];
$withMainFields && $member = array_merge($member, $data);
if ($withMemberDataFields) {
$memberDataDb = $this->_getMemberDataDB();
$data = $memberDataDb->get($userId);
if ($data) $member = array_merge($member, $data);
}
if ($withMemberInfoFields) {
$memberInfoDb = $this->_getMemberInfoDB();
$data = $memberInfoDb->get($userId);
if ($data) $member = array_merge($member, $data);
}
return $member ? $member : null;
}