소스 검색

修改bug

chenbo 4 년 전
부모
커밋
15ac075831

+ 2 - 3
lib/stock.class.php

@@ -8,11 +8,10 @@
 
 class Stock {
 
-
-    static public function getStockCodeList()
+    static public function getAllList()
     {
         $Table_stock = new Table_stock();
-        return $Table_stock->getStockCodeList();
+        return $Table_stock->getList(array(), 0, 0, 0, 1);  //升序
     }
 
     static public function getInfoById($id)

+ 3 - 2
lib/table/table.class.php

@@ -125,11 +125,12 @@ abstract class Table {
     //@param $count -- 0:返回列表 1:返回结果数量
     //@param $page -- 当前第几页
     //@param $pagesize -- 每页数量
-    public function getList($filter = array(), $count = 0, $page = 0, $pagesize = 0){
+    public function getList($filter = array(), $count = 0, $page = 0, $pagesize = 0, $order = 0){
         $where = $this->filterToWhere($filter);
+        $orderByStr = (empty($order) ? 'desc' : 'asc');
 
         if($count == 0){//列表
-            $sql = "select * from ". $this->table_fullname ." $where order by ".$this->table_id." desc";
+            $sql = "select * from ". $this->table_fullname ." $where order by ".$this->table_id." ".$orderByStr;
 
             if($page > 0){//分页
                 $startrow = ($page - 1) * $pagesize;

+ 0 - 27
lib/table/table_stock.class.php

@@ -37,33 +37,6 @@ class Table_stock extends Table {
         return $this->pdo->sqlinsert($this->table_fullname, $param);
     }
 
-
-    /***
-     * @param array $filter
-     * @param int $count
-     * @param int $page
-     * @param int $pagesize
-     * @return array
-     * 获取代码列表
-     * 王刚涛
-     */
-    public function getStockCodeList(){
-
-        $where="where 1=1";
-        $sql = "select "."`*`". "from ". $this->table_fullname ." $where order by ".$this->table_id." asc";
-        $rs  = $this->pdo->sqlQuery($sql);
-        $r  = array();
-        if($rs){
-            foreach($rs as $key => $val){
-                $r[$key] = $this->dataToAttr($val);
-            }
-            return $r;
-        }else{
-            return $r;
-        }
-    }
-
-
     public function getStockList($filter = array(), $count = 0, $page = 0, $pagesize = 0){
         $where=" ";
         if(!empty($filter["sector"])){

+ 1 - 1
task/task_get_day_k_qfq.php

@@ -7,7 +7,7 @@
  * 获取2014-今年所有的每天的前复权数据,每天定时更新
  */
 require('../init.php');
-$codeList=Stock::getStockCodeList();//获取股票代码
+$codeList=Stock::getAllList();//获取股票代码
 $endDate=date("Y",time());
 for($year=2015;$year<=$endDate;$year++)
 {

+ 1 - 1
task/task_get_day_k_stock.php

@@ -7,7 +7,7 @@
  * 获取股票的日K数据,一天大概4000条数据入库
  */
 require('../init.php');
-$codeList=Stock::getStockCodeList();//获取股票代码
+$codeList=Stock::getAllList();//获取股票代码
 
 foreach ($codeList as $key=>$value){
     Input_sina_day_k::get_day_k($value["code"],$value["exchange"]);

+ 1 - 1
task/task_get_history_day_k.php

@@ -10,7 +10,7 @@ require('../init.php');
 
 $start_date=20140101;
 $end_date=date("Ymd",time());
-$indexList=Stock::getStockCodeList();//获取指数代码
+$indexList=Stock::getAllList();//获取指数代码
 foreach ($indexList as $key=>$value){
     Input_163_history_day_k::HistoryDayK($value["code"],$start_date,$end_date);
 }

+ 1 - 1
task/task_get_immediate_stock.php

@@ -6,7 +6,7 @@
  * Time: 19:35 获取股票的日K实时数据,,每4秒获取一次数据,按月进行分表,只存项目上线后的数据,历史数据不存储
  */
 require('../init.php');
-$codeList=Stock::getStockCodeList();//获取股票代码
+$codeList=Stock::getAllList();//获取股票代码
 
 foreach ($codeList as $key=>$value){
     Input_sina_immediate::get_day_k($value["code"],$value["exchange"]);