/** * 拥有学校的城市 */ 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; }
function getCity($id) { $tblRegion = new DB_Howdo_Region(); return $tblRegion->fetchRow($id, "region_id as city_id, region_name as city_name"); }