table_name, 'default'); } public function province() { $result = array(); $list = $this->select(null, null, null, null, 'distinct(province_id), province_name'); if ($list) { foreach ($list as $v) { $result[$v['province_id']] = array( 'id' => $v['province_id'], 'name' => $v['province_name'], ); } } return $result; } public function city($province_id = '', $type = 0) { $result = array(); $list = $this->select(array('province_id' => $province_id), null, null, null, 'distinct(city_id), city_name, firstchar'); $type == 0 && $result[] = array('name' => '城市', 'id' => ''); if ($list) { foreach ($list as $v) { $item = array( 'id' => $v['city_id'], 'name' => $v['city_name'], ); 2 == $type && $item['firstchar'] = $v['firstchar']; $result[$v['city_id']] = $item; } } return $result; } public function county($city_id = '', $type = 0) { $result = array(); $list = $this->select(array('city_id' => $city_id), null, null, null, 'distinct(county_id), county_name'); $type == 0 && $result[] = array('name' => '行政区', 'id' => ''); if ($list) { foreach ($list as $v) { $result[$v['county_id']] = array( 'id' => $v['county_id'], 'name' => $v['county_name'], ); } } return $result; } /** * Notes:根据county_id获取数据 * Created on: 2021/11/16 14:18 * Created by: dengbw * @param $ids * @param string $fileds * @param string $map_key * @return array */ public function get_map_by_county_ids($ids, $fileds = '', $map_key = 'id') { $rows = []; $ids = array_filter($ids); if ($ids) { $cf_ids = implode(',', $ids); $where = [ "county_id in ($cf_ids)" => null ]; $rows = $this->map($map_key, '', $where, '', '', '', $fileds); } return $rows; } }