wanggangtao 5 年之前
父节点
当前提交
9104f9e8bb
共有 4 个文件被更改,包括 45 次插入4 次删除
  1. 1 2
      data/get_boniu_index_csi300.php
  2. 11 0
      data/test.php
  3. 15 0
      lib/stock.class.php
  4. 18 2
      lib/table/table.class.php

+ 1 - 2
data/get_boniu_index_csi300.php

@@ -13,5 +13,4 @@ require('../init.php');
  * 1。获取所有的股票代码
  * 2.遍历股票代码,住区数据,插入到数据库中
  */
-
-var_dump(Sina::get_boniu_index_csi300());
+Sina::get_boniu_index_csi300();

+ 11 - 0
data/test.php

@@ -0,0 +1,11 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: 王刚涛
+ * Date: 2020/11/26
+ * Time: 20:37
+ */
+require('../init.php');
+
+$CodeList=Stock::getStockCodeList();//默认是今天
+var_dump($CodeList);

+ 15 - 0
lib/stock.class.php

@@ -36,6 +36,21 @@ class Stock {
         return $Table_stock->getList($filter, $count, $page, $pageSize);
     }
 
+    /****
+     * @param array $filter
+     * @param int $count
+     * @param int $page
+     * @param int $pageSize
+     * @return array|int
+     * 获取股票的代码列表
+     */
+    static public function getStockCodeList()
+    {
+        $Table_stock = new Table_stock();
+        return $Table_stock->getStockCodeList();
+    }
+
+
     static public function updateCodeAndName($attrs)
     {
         if (empty($attrs)) throw new Exception('参数不能为空', 101);

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

@@ -57,9 +57,7 @@ abstract class Table {
 
 		//查询语句必须用sql_check_input检查参数
 		$id = $this->pdo->sql_check_input(array('number', $id));
-        
         $sql = "select * from ". $this->table_fullname ." where ". $this->table_id ." = $id limit 1";
-        
         $rs = $this->pdo->sqlQuery($sql);
         $r  = array();
 		if($rs){
@@ -72,6 +70,24 @@ abstract class Table {
         }
 	}
 
+    public function getStockCodeList($filter = array(), $count = 0, $page = 0, $pagesize = 0){
+
+        $where="where 1=1";
+        $sql = "select "."`stock_code`". "from ". $this->table_fullname ." $where order by ".$this->table_id." desc";
+        var_dump($sql);
+        $rs  = $this->pdo->sqlQuery($sql);
+        $r   = array();
+        if($rs){
+            foreach($rs as $key => $val){
+                $r[$key] = $this->dataToAttr($val);
+            }
+            return $r;
+        }else{
+            return $r;
+        }
+
+        }
+
     //获取列表(分页)
     //$count、$page和$pagesize都为0时,返回全部结果(适用于无需分页的情况)
     //