初始化代码

This commit is contained in:
2025-08-11 10:22:05 +08:00
commit ebd8d85201
4206 changed files with 753018 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
<?php
namespace app\admin\model;
use think\Db;
class ReloadDb
{
private static $time = null;
/**
* 检测或执行主动重连
* @author andy3513
* @param int $timeout 超时时间
* @param array $config 连接参数
*/
public static function init($timeout = 7200,$config = []){
$time = time();
if(null === self::$time){
self::$time = $time;
}
$exprie = $time - self::$time;
if($exprie >= $timeout){
Db::connect($config, true);
self::$time = $time;
}
}
}