You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
77 lines
1.9 KiB
PHP
77 lines
1.9 KiB
PHP
<?php
|
|
class flight_model extends CI_Model{
|
|
|
|
function __construct(){
|
|
parent::__construct();
|
|
$this->INFO = $this->load->database('INFO', TRUE);
|
|
$this->HT=$this->load->database('HT',TRUE);
|
|
}
|
|
|
|
|
|
//public $FlightAPI_Code = "http://202.103.68.156:9032"; //本地
|
|
public $FlightAPI_Code = "https://www.trainspread.com"; //网前
|
|
|
|
public function getAllCityCodeAndName(){
|
|
$sql = "select city_chinese_name,city_english_name,city_threeChar from city_threeChar";
|
|
$query = $this->INFO->query($sql);
|
|
return $query->result();
|
|
}
|
|
|
|
public function getAllAirPort(){
|
|
$sql = "select air_threeChar,air_english_name from air_threeChar";
|
|
$query = $this->INFO->query($sql);
|
|
return $query->result();
|
|
}
|
|
|
|
/**
|
|
* 根据机场code获取对于的机场英文名 20201229 zp 接口数据突然无法获取机场英文名,估计是删除缓存获取以后的错误
|
|
*/
|
|
public function getAirPortNameEn($code){
|
|
$sql = "select top 1 air_english_name from air_threeChar where air_threeChar ='".$code."'";
|
|
$query = $this->INFO->query($sql);
|
|
$row = $query->row();
|
|
if (isset($row)){
|
|
return $row->air_english_name;
|
|
}else{
|
|
return "";
|
|
}
|
|
}
|
|
|
|
/*
|
|
* 根据三字码获取对应城市的英文名称
|
|
*/
|
|
public function getCityNameFromCode($code){
|
|
$result = "";
|
|
$Url_FlightCode = $this->FlightAPI_Code."/flight/ajaxGetCodeAndName/";
|
|
$FlightCodeList = get_http($Url_FlightCode); //获取接口机场列表Json
|
|
$Json_FlightCode = json_decode($FlightCodeList);
|
|
if (!empty($code)){
|
|
foreach($Json_FlightCode as $Item){
|
|
if ($Item->city_threeChar==$code){
|
|
$result=$Item->city_english_name;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
return $result;
|
|
}
|
|
|
|
/*
|
|
* 根据航线二字码获取对应的航空公司英文名
|
|
*/
|
|
public function getAirlineNameEn($code){
|
|
$sql = "select top 1 NameEN,NameCN from AirCompany where Code='".$code."'";
|
|
$query = $this->HT->query($sql);
|
|
$row = $query->row();
|
|
if (isset($row)){
|
|
return $row->NameEN;
|
|
}else{
|
|
return "";
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
?>
|