/** * 省市区三级结构 */ function getRegion() { $tblRegion = new DB_Howdo_Region(); $list = $tblRegion->fetchAll("region_id,pid,region_name", "", "order by pid asc, region_id asc"); $data = array(); foreach ($list as $row) { $data[$row['pid']][$row['region_id']] = $row['region_name']; } return $data; }
/** * 拥有学校的城市 */ function getCities() { $tbl = new DB_Haodu_School(); $cities = $tbl->fetchAll("city_id"); if (!$cities) { return false; } $cityIds = $tbl->columnRow($cities, "city_id"); $tblRegion = new DB_Howdo_Region(); $cities = $tblRegion->fetchAll("region_id as id, region_name as name", "where region_id in (" . implode(",", $cityIds) . ")"); if (!$cities) { return false; } return $cities; }
/** * 通过uid获得用户信息 * @param $id * @return array */ public function getUser($uid, $fields = 'stuff_id, stuff_name, mobile, sentence as sign, gender, avator, prov_id, city_id, area_id, grade, school') { $user = new DB_Howdo_User(); $user = $user->fetchRow($uid, $fields); if ($user && $user['prov_id']) { $tblRegion = new DB_Howdo_Region(); $regions = $tblRegion->fetchAll("region_id,region_name", "where region_id in ({$user['prov_id']},{$user['city_id']},{$user['area_id']})", "order by region_id asc"); $user['prov'] = @$regions[0]; $user['city'] = @$regions[1]; $user['area'] = @$regions[2]; } if ($user) { $user['avator'] = empty($user['avator']) ? Common_Config::DEFAULT_AVATOR : $user['avator']; $user['avator'] = Common_Config::AVATOR_BASE_URL . $user['avator']; } return $user; }