mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 12:42:48 +08:00
增加use_db_switch参数 支持数据库跟随app_status配置多个连接
This commit is contained in:
@@ -136,8 +136,9 @@ return [
|
||||
// +----------------------------------------------------------------------
|
||||
// | 数据库设置
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
'db_like_fields' => '',
|
||||
|
||||
// 是否启用多状态数据库配置 如果启用的话 需要跟随app_status配置不同的数据库信息
|
||||
'use_db_switch' => false,
|
||||
'database' => [
|
||||
// 数据库类型
|
||||
'type' => 'mysql',
|
||||
|
||||
@@ -54,6 +54,9 @@ class Db
|
||||
{
|
||||
if (empty($config)) {
|
||||
$config = Config::get('database');
|
||||
if (Config::get('use_db_switch')) {
|
||||
$config = $config[Config::get('app_status')];
|
||||
}
|
||||
}
|
||||
if (is_string($config)) {
|
||||
return self::parseDsn($config);
|
||||
|
||||
Reference in New Issue
Block a user