大佬帮忙看下
// 配置 Db::setConfig(config('thinkorm')); // 维持mysql心跳 if ($businessWorker) { Timer::add(55, function () { if (!class_exists(Mysql::class, false)) { return; } $connections = config('thinkorm.connections', []); foreach ($connections as $key => $item) { if ($item['type'] == 'mysql') { try { Db::connect($key)->query('select 1'); } catch (\Throwable $e) {} } } Db::getDbLog(true); }); }
// 配置
Db::setConfig(config('thinkorm'));
// 维持mysql心跳
if ($businessWorker) {
Timer::add(55, function () {
if (!class_exists(Mysql::class, false)) {
return;
}
$connections = config('thinkorm.connections', []);
foreach ($connections as $key => $item) {
if ($item['type'] == 'mysql') {
try {
Db::connect($key)->query('select 1');
} catch (\Throwable $e) {}
}
}
Db::getDbLog(true);
});
}