wanggangtao 5 anos atrás
pai
commit
2e3f42d805
2 arquivos alterados com 13 adições e 13 exclusões
  1. 2 1
      lib/sina.class.php
  2. 11 12
      lib/table/table_index_sh.class.php

+ 2 - 1
lib/sina.class.php

@@ -44,7 +44,8 @@ class sina
         $content3=sina::curl_get_data($url);
         $data['increase_value'] = floatval($content3[3]);//涨跌率
         $data2=self::get_info_code($code);//调用另一个函数获取其他数据如开盘价等等
-        $data['increase_price']  =  0;   // 涨跌价
+        $data['increase_price']  = floatval($data2[3]-$data2[2]);//涨跌
+        // 涨跌价-当日股票最新价与前一日收盘价格(或前一日收盘指数)
         $data['date'] = strtotime(date('Y-m-d',time()));//当天的0点时间戳
         $data['open_price'] = floatval($data2[1]);//开盘价
         $data['close_price'] = floatval($data2[3]);//3点之后的当前价格就是收盘价

+ 11 - 12
lib/table/table_index_sh.class.php

@@ -17,16 +17,16 @@ class Table_index_sh extends Table {
 	//数据库结构
 	protected function struct(){
 		$attr = array();
-		
-		$attr['id']           = 'index_sh_id';
-		$attr['date']         = 'index_sh_date';
-		$attr['open_price']         = 'index_sh_open_price';
-		$attr['close_price']        = 'index_sh_close_price';
-        $attr['increase_price']           = 'index_sh_increase_price';
-        $attr['increase_value']         = 'index_sh_increase_value';
-        $attr['amount']         = 'index_sh_amount';
-        $attr['value']        = 'index_sh_value';
-		return $attr;
+		$attr['id']              =   'index_sh_id';
+		$attr['date']            =   'index_sh_date';
+		$attr['open_price']      =    'index_sh_open_price';
+		$attr['close_price']     =    'index_sh_close_price';
+        $attr['increase_price']  =    'index_sh_increase_price';
+        $attr['increase_value']  =    'index_sh_increase_value';
+        $attr['amount']          =    'index_sh_amount';
+        $attr['value']           =    'index_sh_value';
+		return    $attr;
+
 	}
 
     public function add($attr){
@@ -40,9 +40,8 @@ class Table_index_sh extends Table {
             'index_sh_increase_price'    => array('number', $attr['increase_price']),
             'index_sh_amount'    => array('number', $attr['amount']),
             'index_sh_value'    => array('number', $attr['value']),
-
         );
-//var_dump($param);
+
         return $this->pdo->sqlinsert($this->table_fullname, $param);
     }