From c36065fb5b46cce3933a5d65b375f81a866c0324 Mon Sep 17 00:00:00 2001 From: WispX <1591788658@qq.com> Date: Sat, 13 Oct 2018 10:23:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E5=88=86=E7=A6=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- application/index/controller/Install.php | 6 +++--- config/database.php | 14 +++----------- config/db.php | 20 ++++++++++++++++++++ 4 files changed, 27 insertions(+), 15 deletions(-) create mode 100644 config/db.php diff --git a/README.md b/README.md index e623c734..868f94f3 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ Apache直接使用.htaccess即可 4. 访问首页,未安装自动跳转至安装页面,根据页面提示安装即可。 -5. 安装完成以后请设置runtime目录0777权限,如果你使用本地存储,public 目录也需要设置为0777权限 +5. 安装完成以后请设置runtime目录0755权限,如果你使用本地存储,public 目录也需要设置为0755权限 联系我 --- diff --git a/application/index/controller/Install.php b/application/index/controller/Install.php index 878e5011..e99ed8e8 100644 --- a/application/index/controller/Install.php +++ b/application/index/controller/Install.php @@ -65,8 +65,8 @@ class Install extends Controller if (!$mysqli->multi_query($sqlFile)) { throw new Exception('数据写入失败'); } - $dataBasePath = $configPath . 'database.php'; - $dataBaseFile = file_get_contents($dataBasePath); + $dbPath = $configPath . 'db.php'; + $dataBaseFile = file_get_contents($dbPath); $dataBaseFile = str_replace([ '{hostname}', '{database}', @@ -81,7 +81,7 @@ class Install extends Controller $hostport, ], $dataBaseFile); - file_put_contents($dataBasePath, $dataBaseFile); + file_put_contents($dbPath, $dataBaseFile); } catch (Exception $e) { return $this->error($e->getMessage()); diff --git a/config/database.php b/config/database.php index 6afcc175..3f348f4f 100644 --- a/config/database.php +++ b/config/database.php @@ -9,19 +9,9 @@ // | Author: liu21st // +---------------------------------------------------------------------- -return [ +$database = [ // 数据库类型 'type' => 'mysql', - // 服务器地址 - 'hostname' => '{hostname}', - // 数据库名 - 'database' => '{database}', - // 用户名 - 'username' => '{username}', - // 密码 - 'password' => '{password}', - // 端口 - 'hostport' => '{hostport}', // 连接dsn 'dsn' => '', // 数据库连接参数 @@ -61,3 +51,5 @@ return [ // 断线标识字符串 'break_match_str' => [], ]; + +return array_merge($database, require(\think\facade\Env::get('config_path') . 'db.php')); \ No newline at end of file diff --git a/config/db.php b/config/db.php new file mode 100644 index 00000000..5f238e9f --- /dev/null +++ b/config/db.php @@ -0,0 +1,20 @@ + '{hostname}', + // 数据库名 + 'database' => '{database}', + // 用户名 + 'username' => '{username}', + // 密码 + 'password' => '{password}', + // 端口 + 'hostport' => '{hostport}', +]; \ No newline at end of file