feat: Refactor database connection handling to use centralized configuration

This commit is contained in:
杨水淼
2025-11-12 16:00:32 +08:00
parent 8303ae39f1
commit 4c348e379d
11 changed files with 86 additions and 92 deletions
+5 -5
View File
@@ -1,5 +1,5 @@
<?php
include_once __DIR__."/config.php";
/*
上证指数:000001.SH
深证成指:399001.SZ
@@ -7,7 +7,7 @@
创业板指:399006.SZ
*/
function getIndexData($ts_code,$day_st,$day_end){
$mysqli = new mysqli('localhost','root','nancysimon','myquant');
$mysqli = get_mysqli_connection();
#$ts_code = '000001.SH';
#$day_st = '20000101';
@@ -43,7 +43,7 @@ return array('tDate'=>$tDate,'idx'=>$idx,'data'=>$data);
#share: vposition 市值 f10, sahreHDnum 股数 f9
*/
function getIhData($lx,$share,$day_st,$day_end){
$mysqli = new mysqli('localhost','root','nancysimon','myquant');
$mysqli = get_mysqli_connection();
/*
$where = " and rdate>='".$day_st."'";
if($day_end) $where .= " and rdate<='".$day_end."'";
@@ -176,7 +176,7 @@ function hkholdConv($code){
#LX: tp字段: 序号 1-6,分别代表基金,QFII, 社保,券商,保险,信托
*/
function getIhDataByStock($ts_code,$item,$lx,$day_st,$day_end){
$mysqli = new mysqli('localhost','root','nancysimon','myquant');
$mysqli = get_mysqli_connection();
$where = " and ih_date>'".$day_st."'";
if($day_end) $where .= " and ih_date<'".$day_end."'";
if($lx) $where .= " and tp='".$lx."'";
@@ -219,7 +219,7 @@ EOF;
}
function getMoneyFlowData($itm, $day_st,$day_end, $stacked){
$mysqli = new mysqli('localhost','root','nancysimon','myquant');
$mysqli = get_mysqli_connection();
if($stacked==1) $tb = 'moneyflow_hsgt_pro_ext';
else $tb = 'moneyflow_hsgt_pro';