示例#1
0
 /**
  * 获取城市据点信息
  */
 public function get_city_info($city_id, $field = null)
 {
     if (is_array($city_id)) {
         $cache = array();
         $data = array();
         foreach ($city_id as $key => $val) {
             if (isset($this->city_configs[$val])) {
                 $cache[$val] = $this->city_configs[$val];
                 unset($city_id[$key]);
             }
         }
         if (!empty($city_id)) {
             $sql = "select * from city where city_id in (#city_id#)";
             $data = $this->get_list($sql, 'city_id', $city_id);
             foreach ($data as $key => $val) {
                 if (count($this->city_configs) > $this->size) {
                     Com_Array::shift($this->city_configs);
                 }
                 $this->city_configs[$key] = $val;
             }
         }
         foreach ($cache as $key => $val) {
             $data[$key] = $val;
         }
         return $data;
     }
     $data = array();
     $city_id = intval($city_id);
     if ($city_id < 1) {
         return array();
     }
     if (!isset($this->city_configs[$city_id])) {
         $cache_key = $this->get_cache_key(array('city_id' => $city_id));
         $sql = "select * from city where city_id='{$city_id}'";
         $data = $this->select_one($sql, $cache_key);
         if (empty($data)) {
             return array();
         }
         if (count($this->city_configs) > $this->size) {
             Com_Array::shift($this->city_configs);
         }
         $this->city_configs[$city_id] = $data;
     } else {
         $data = $this->city_configs[$city_id];
     }
     return Com_Array::get_arr_field($data, $field);
 }