|
@@ -71,43 +71,26 @@ class Table_index_day_k extends Table {
|
|
|
* wanggangtao
|
|
* wanggangtao
|
|
|
* 获取某天的指数代码
|
|
* 获取某天的指数代码
|
|
|
*/
|
|
*/
|
|
|
- public function get_current_day_index($index_type,$date)
|
|
|
|
|
|
|
+ public function get_current_day_index($code,$date)
|
|
|
{
|
|
{
|
|
|
//查询语句必须用sql_check_input检查参数
|
|
//查询语句必须用sql_check_input检查参数
|
|
|
- $stock_code = $this->pdo->sql_check_input(array('number', $index_type));//类型是字符串,那一定要在条件中将数据使用引号引用起来,否则不使用索引
|
|
|
|
|
|
|
+ $stock_code = $this->pdo->sql_check_input(array('string', $code));//类型是字符串,那一定要在条件中将数据使用引号引用起来,否则不使用索引
|
|
|
$sql = "select * from ". $this->table_fullname ;
|
|
$sql = "select * from ". $this->table_fullname ;
|
|
|
|
|
|
|
|
$where=" where 1=1 ";
|
|
$where=" where 1=1 ";
|
|
|
- if($index_type==1){
|
|
|
|
|
- $stock_code="000001";
|
|
|
|
|
- $where.=" and index_day_k_code=".$stock_code ;
|
|
|
|
|
- }else if($index_type==2){
|
|
|
|
|
- $stock_code="399001";
|
|
|
|
|
- $where.=" and index_day_k_code=".$stock_code ;
|
|
|
|
|
- }else if($index_type==3){
|
|
|
|
|
- $stock_code="000016";
|
|
|
|
|
- $where.=" and index_day_k_code=".$stock_code ;
|
|
|
|
|
- }else if($index_type==4){
|
|
|
|
|
- $stock_code="399300";
|
|
|
|
|
- $where.=" and index_day_k_code=".$stock_code ;
|
|
|
|
|
- }else if($index_type==5){
|
|
|
|
|
- $stock_code="399006";
|
|
|
|
|
- $where.=" and index_day_k_code=".$stock_code ;
|
|
|
|
|
- }else if($index_type==6){
|
|
|
|
|
- $stock_code="000688";
|
|
|
|
|
- $where.=" and index_day_k_code=".$stock_code ;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ $where.=" and index_day_k_code=".$stock_code ;
|
|
|
|
|
|
|
|
-
|
|
|
|
|
- if($date==0){//获取的是当天的数据
|
|
|
|
|
|
|
+ if($date==0){//获取的是当天的数据,最近一天的交易日的数据
|
|
|
$date = date("Ymd",time());
|
|
$date = date("Ymd",time());
|
|
|
- $where.=" and index_day_k_date = ".$date;
|
|
|
|
|
|
|
+ $where.=" and index_day_k_date <= ".$date;
|
|
|
|
|
|
|
|
- }else{//获取某一天的数据
|
|
|
|
|
|
|
+ }else{//获取某一天的数据,不是交易日则返回空
|
|
|
$date = $this->pdo->sql_check_input(array('number', $date));
|
|
$date = $this->pdo->sql_check_input(array('number', $date));
|
|
|
$where.=" and index_day_k_date =".$date;
|
|
$where.=" and index_day_k_date =".$date;
|
|
|
}
|
|
}
|
|
|
$sql.=$where;
|
|
$sql.=$where;
|
|
|
|
|
+ $order=" order by index_day_k_date desc limit 1 ";
|
|
|
|
|
+ $sql.=$order;
|
|
|
|
|
|
|
|
$rs = $this->pdo->sqlQuery($sql);
|
|
$rs = $this->pdo->sqlQuery($sql);
|
|
|
$r = array();
|
|
$r = array();
|