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.
information-system/application/third_party/updatetrain/models/station_model.php

143 lines
4.3 KiB
PHTML

<?php
6 years ago
/*
* @Author: your name
* @Date: 2020-01-15 11:28:41
* @LastEditTime : 2020-01-17 11:00:42
* @LastEditors : Please set LastEditors
* @Description: In User Settings Edit
* @FilePath: \information-system\application\third_party\updatetrain\models\station_model.php
*/
6 years ago
defined('BASEPATH') or exit('No direct script access allowed');
6 years ago
class station_model extends CI_Model
{
6 years ago
function __construct()
{
parent::__construct();
$this->HT = $this->load->database('HT', TRUE);
}
6 years ago
/**
* @description: 判断数据库里面是否有该站点的信息
* @param {type}$code 三字码,$name 车站名
* @return: bool
*/
6 years ago
function GetStationCount($code, $name)
{
$sql = " select top 1 * from TrainStation
6 years ago
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;
6 years ago
} else {
return true;
}
6 years ago
}
/**
* @description: 通过比较中文名三字码判断HT的站点信息是否存在或变动
* @param {type}
* @return: 0表示站点已存在 1表示站点存在但是更新2表示站点未存在
*/
function CompareStation($code, $name)
{
6 years ago
$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 0;
} else {
$sql2 = " select top 1 * from TrainStation where TRS_StationCN='" . $name . "'";
$query2 = $this->HT->query($sql2);
if ($query2->result()) {
return 1;
} else {
return 2;
}
}
}
6 years ago
/**
* @description: 获取HT里面的站点信息列表
* @param {type}
* @return:
*/
6 years ago
function GetStationList()
{
$sql = "select TRS_ID,TRS_StationCN,TRS_Station,TRS_Code FROM TrainStation where TRS_Use=1";
$query = $this->HT->query($sql);
return $query->result();
}
/**
* @description: 增加新站点
* @param {type}
* @return:
*/
6 years ago
function AddStation($data)
{
//TrainStation表
$sql = "
insert into TrainStation (TRS_StationCN,TRS_Station,LastEditTime,TRS_Code,TRS_Use,TRS_IsNew)
values(?,?,getdate(),?,1,1)
";
6 years ago
$param = array($data["StationCN"], $data["Station"], $data["Code"]);
$query = $this->HT->query($sql, $param);
$TRS_ID = $this->HT->insert_id();
//语种表TrainStation2,中英文都得添加
6 years ago
$sql2 = " insert into TrainStation2 (TS2_Name,TS2_LGC,TS2_TRSID,LastEditTime)
values(?,1,?,GETDATE())";
6 years ago
$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())";
6 years ago
$param = array($data["StationCN"], $TRS_ID);
$query = $this->HT->query($sql2, $param);
}
/**
* @description: 更新已存在的站点名称的三字码
* @param {type}
* @return:
*/
function UpdateStation($code, $name)
{
6 years ago
//$name = iconv("utf-8", "gb2312//IGNORE", $name);
$sql = "update TrainStation set TRS_Code=? where TRS_StationCN='".$name."'";
6 years ago
$param = array($code);
$query = $this->HT->query($sql, $param);
}
6 years ago
function SendMail($fromName, $fromEmail, $toName, $toEmail, $subject, $body)
{
$toName = str_replace("'", "''", $toName);
$body = str_replace("'", "''", $body);
$sql = "INSERT INTO Email_AutomaticSend
(
M_ReplyToName, M_ReplyToEmail, M_ToName, M_ToEmail, M_Title, M_Body, M_Web,
M_FromName, M_State
)
VALUES
(
?, ?, N'{$toName}', ?, N'{$subject}', N'{$body}', ?, ?, 0
) ";
$query = $this->HT->query($sql, array($fromName, $fromEmail, $toEmail, 'cht', 'information'));
echo $query;
6 years ago
//return $query;
}
}
/* End of file station_model.php */