wanggangtao 5 gadi atpakaļ
vecāks
revīzija
bab751956f
2 mainītis faili ar 45 papildinājumiem un 23 dzēšanām
  1. 2 2
      lib/day_k_base.class.php
  2. 43 21
      lib/table/table_day_k_base.class.php

+ 2 - 2
lib/day_k_base.class.php

@@ -36,8 +36,8 @@ class Day_k_base {
 	static public function getCountAll(){
 		$filter = array();
 
-        $Table_xrxd_log = new Table_st_log();
-		return $Table_xrxd_log->getList($filter, 1);
+        $Table_day_k_base = new Table_st_log();
+		return $Table_day_k_base->getList($filter, 1);
 	}
 }
 ?>

+ 43 - 21
lib/table/table_day_k_base.class.php

@@ -1,53 +1,75 @@
 <?php
 
 /**
- * 数据库表:管理员组
- *
- * @createtime	2018/03/01
- * @author		空竹
- * @copyright	芝麻开发(http://www.zhimawork.com)
+ * Created by PhpStorm.
+ * User: 王刚涛
+ * Date: 2020/11/24
+ * Time: 14:51
  */
 
 class Table_day_k_base extends Table {
 
-	protected $table_name       = 'day_k_base';//表名,不带前缀,前缀在config中定义
-    protected $table_id         = 'day_k_id';//指定ID字段名称,必须
+    protected $base  = "";              //分表的后缀日期,在进行数据库操作的时候"Table_day_k_".$base
+    protected $table_name       = "";//表名,不带前缀,前缀在config中定义
+    protected $table_id         = "day_k_id";//指定ID字段名称,必须
     protected $table_status     = '';//指定状态字段名称,如果有
     protected $table_order      = '';//指定排序字段名称,如果有
+    protected $table_fullname    = "";//拼接好后表名
+
 	//数据库结构
 	protected function struct(){
 		$attr = array();
-		$attr['id']                 = 'day_k_id';
-		$attr['date']               = 'day_k_date';
-		$attr['code']         = 'day_k_code';
-		$attr['type']        = 'day_k_open_price';
-        $attr['multiple']    = 'day_k_close_price';
+		$attr['id']              = 'day_k_id';
+		$attr['date']            = 'day_k_date';
+		$attr['code']            = 'day_k_code';
+		$attr['type']            = 'day_k_open_price';
+        $attr['multiple']        = 'day_k_close_price';
         $attr['subprice']        = 'day_k_hightest_price';
-        $attr['oldprice']    = 'day_k_lowest_price';
+        $attr['oldprice']        = 'day_k_lowest_price';
         $attr['newprice']        = 'day_k_increase_price';
-        $attr['oldprice']    = 'day_k_increase_value';
+        $attr['oldprice']        = 'day_k_increase_value';
         $attr['newprice']        = 'day_k_turnover';
-        $attr['oldprice']    = 'day_k_amount';
+        $attr['oldprice']        = 'day_k_amount';
         $attr['newprice']        = 'day_k_value';
-        $attr['oldprice']    = 'day_k_open_price_qfq';
+        $attr['oldprice']        = 'day_k_open_price_qfq';
         $attr['newprice']        = 'day_k_close_price_qfq';
         $attr['newprice']        = 'day_k_hightest_price_qfq';
-        $attr['oldprice']    = 'day_k_lowest_price_qfq';
+        $attr['oldprice']        = 'day_k_lowest_price_qfq';
         $attr['newprice']        = 'day_k_m5';
         $attr['newprice']        = 'day_k_m10';
-        $attr['oldprice']    = 'day_k_m20';
+        $attr['oldprice']        = 'day_k_m20';
         $attr['newprice']        = 'day_k_m60';
         $attr['newprice']        = 'day_k_kdj';
-        $attr['oldprice']    = 'day_k_macd';
+        $attr['oldprice']        = 'day_k_macd';
         $attr['newprice']        = 'day_k_rsi';
 		return $attr;
 	}
 
+    /***
+     * Table_day_k_base constructor.
+     * 构造函数,动态获取表的后缀年月
+     * 王刚涛
+     */
+    public function __construct($base) {
+        $this->base=date("Ym");
+        $this->table_name= "day_k_".$base;//表名不代前缀
+        $this->table_fullname= "boniu_"."day_k_".$base;//表名代前缀
+        $this ->createBaseTable();
+    }
+
+    /****
+     *在构造函数中调用该函数,自动创建表
+     * 王刚涛
+     */
+     public function createBaseTable(){
+       $sqlarr[] = "CREATE TABLE IF NOT EXISTS `". $this->table_fullname."` as select * from boniu_day_k_base where 0 ";
+
+   }
+
+
     public function add($attr){
         $param = array (
-
              'admingroup_name'    => array('string', $attr['name'])
-
         );
         return $this->pdo->sqlinsert($this->table_fullname, $param);
     }