基础配置与底层修改

This commit is contained in:
wanyongkang
2020-11-17 10:18:30 +08:00
parent 7fac08ac47
commit cc1bce4672
7 changed files with 140 additions and 39 deletions

View File

@@ -136,7 +136,15 @@ class Fastphp
//配置数据库信息
public function setDbConfig()
{
if (isset($this->config['db'])) {
$formal_origin = $this->config['formal_origin']; //跨域访问的时候才会存在此字段
$origin = isset($_SERVER['HTTP_ORIGIN']) ? $_SERVER['HTTP_ORIGIN'] : '';
if (in_array($origin, $formal_origin)) {
define('DB_HOST', $this->config['formal_db']['host']);
define('DB_PORT', $this->config['formal_db']['port']);
define('DB_NAME', $this->config['formal_db']['dbname']);
define('DB_USER', $this->config['formal_db']['username']);
define('DB_PASS', $this->config['formal_db']['password']);
} else {
define('DB_HOST', $this->config['db']['host']);
define('DB_PORT', $this->config['db']['port']);
define('DB_NAME', $this->config['db']['dbname']);