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