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.
75 lines
2.1 KiB
PHTML
75 lines
2.1 KiB
PHTML
6 years ago
|
<?php
|
||
|
|
||
|
|
||
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||
|
|
||
|
class station_model extends CI_Model {
|
||
|
|
||
|
function __construct() {
|
||
|
parent::__construct();
|
||
|
$this->HT = $this->load->database('HT', TRUE);
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* @description: 判断数据库里面是否有该站点的信息
|
||
|
* @param {type}$code 三字码,$name 车站名
|
||
|
* @return: bool
|
||
|
*/
|
||
|
function GetStationCount($code,$name){
|
||
|
$sql = " select top 1 * from TrainStation
|
||
|
where TRS_Code=? and TRS_StationCN='".$name."'";
|
||
|
$name = iconv ( "utf-8", "gb2312//IGNORE", $name );
|
||
|
$query = $this->HT->query($sql,array($code));
|
||
|
if ($query->result()){
|
||
|
return false;
|
||
|
}else{
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @description: 获取HT里面的站点信息列表
|
||
|
* @param {type}
|
||
|
* @return:
|
||
|
*/
|
||
|
function GetStationList(){
|
||
|
$sql = "select TRS_StationCN,TRS_Station,TRS_Code FROM TrainStation where TRS_Use=1";
|
||
|
$query = $this->HT->query($sql);
|
||
|
return $query->result();
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* @description: 增加新站点
|
||
|
* @param {type}
|
||
|
* @return:
|
||
|
*/
|
||
|
function AddStation($data){
|
||
|
|
||
|
//TrainStation表
|
||
|
$sql = "
|
||
|
insert into TrainStation (TRS_StationCN,TRS_Station,LastEditTime,TRS_Code,TRS_Use,TRS_IsNew)
|
||
|
values(?,?,getdate(),?,1,1)
|
||
|
";
|
||
|
$param = array($data["StationCN"],$data["Station"],$data["Code"]);
|
||
|
$query = $this->HT->query($sql,$param);
|
||
|
$TRS_ID = $this->HT->insert_id();
|
||
|
|
||
|
//语种表TrainStation2,中英文都得添加
|
||
|
$sql2=" insert into TrainStation2 (TS2_Name,TS2_LGC,TS2_TRSID,LastEditTime)
|
||
|
values(?,1,?,GETDATE())";
|
||
|
$param = array($data["Station"],$TRS_ID);
|
||
|
$query = $this->HT->query($sql2,$param);
|
||
|
$sql2=" insert into TrainStation2 (TS2_Name,TS2_LGC,TS2_TRSID,LastEditTime)
|
||
|
values(?,2,?,GETDATE())";
|
||
|
$param = array($data["StationCN"],$TRS_ID);
|
||
|
$query = $this->HT->query($sql2,$param);
|
||
|
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* End of file station_model.php */
|