From 389b4c7dd2619a3d34a1c6d3fcde57b526f1ffc2 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 31 Aug 2016 11:43:05 +0800 Subject: [PATCH] =?UTF-8?q?=E7=8E=AF=E5=A2=83=E5=8F=98=E9=87=8F=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E6=96=87=E4=BB=B6=E6=9B=B4=E6=94=B9=E4=B8=BA=20.env?= =?UTF-8?q?=20=E4=B8=8D=E5=86=8D=E4=BD=BF=E7=94=A8php=E6=95=B0=E7=BB=84?= =?UTF-8?q?=E6=96=B9=E5=BC=8F=E5=AE=9A=E4=B9=89=20=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E5=85=BC=E5=AE=B9ini=E6=A0=BC=E5=BC=8F=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=EF=BC=88=E6=94=AF=E6=8C=81=E6=95=B0=E7=BB=84=E6=96=B9=E5=BC=8F?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- base.php | 16 +++++++++------- library/think/db/Query.php | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/base.php b/base.php index 28de4b51..bf1276f2 100644 --- a/base.php +++ b/base.php @@ -38,16 +38,18 @@ define('IS_WIN', strpos(PHP_OS, 'WIN') !== false); require CORE_PATH . 'Loader.php'; // 加载环境变量配置文件 -if (is_file(ROOT_PATH . 'env' . EXT)) { - $env = include ROOT_PATH . 'env' . EXT; +if (is_file(ROOT_PATH . '.env')) { + $env = parse_ini_file(ROOT_PATH . '.env', true); foreach ($env as $key => $val) { $name = ENV_PREFIX . strtoupper($key); - if (is_bool($val)) { - $val = $val ? 1 : 0; - } elseif (!is_scalar($val)) { - continue; + if (is_array($val)) { + foreach ($val as $k => $v) { + $item = $name . '_' . strtoupper($k); + putenv("$item=$v"); + } + } else { + putenv("$name=$val"); } - putenv("$name=$val"); } } diff --git a/library/think/db/Query.php b/library/think/db/Query.php index 35cb5dd4..a88fc13d 100644 --- a/library/think/db/Query.php +++ b/library/think/db/Query.php @@ -1227,7 +1227,7 @@ class Query /** * 设置查询数据不存在是否抛出异常 * @access public - * @param bool $fail 是否严格检查字段 + * @param bool $fail 数据不存在是否抛出异常 * @return $this */ public function failException($fail = true)