mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-08 15:42:48 +08:00
优化think/cache/driver/Db.php驱动,支持单独配置,兼容默认database配置
This commit is contained in:
19
library/think/cache/driver/Db.php
vendored
19
library/think/cache/driver/Db.php
vendored
@@ -29,11 +29,18 @@ class Db
|
|||||||
|
|
||||||
protected $handler = null;
|
protected $handler = null;
|
||||||
protected $options = [
|
protected $options = [
|
||||||
'db' => '',
|
'type' => '',
|
||||||
'table' => '',
|
'dsn' => '',
|
||||||
'prefix' => '',
|
'hostname' => '',
|
||||||
'expire' => 0,
|
'hostport' => '',
|
||||||
'length' => 0,
|
'username' => '',
|
||||||
|
'password' => '',
|
||||||
|
'database' => '',
|
||||||
|
'charset' => '',
|
||||||
|
'table' => '',
|
||||||
|
'prefix' => '',
|
||||||
|
'expire' => 0,
|
||||||
|
'length' => 0,
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -46,7 +53,7 @@ class Db
|
|||||||
if (!empty($options)) {
|
if (!empty($options)) {
|
||||||
$this->options = array_merge($this->options, $options);
|
$this->options = array_merge($this->options, $options);
|
||||||
}
|
}
|
||||||
$this->handler = \Think\Db::connect();
|
$this->handler = \think\Db::connect((!empty($this->options['hostname']) || !empty($this->options['dsn'])) ? $this->options : []);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user