From 3ef9177ea243ef5636ce60062fbb2e7d053bbf45 Mon Sep 17 00:00:00 2001 From: Ying Date: Wed, 24 Aug 2022 15:49:41 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=A6=86=E7=9B=96?= =?UTF-8?q?=E5=AE=89=E8=A3=85=E5=BA=93=E5=AD=98=E5=9C=A8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/install/controller/Index.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/app/install/controller/Index.php b/app/install/controller/Index.php index d9ca3b6..13c028f 100644 --- a/app/install/controller/Index.php +++ b/app/install/controller/Index.php @@ -132,21 +132,22 @@ class Index extends BaseController // 检测MySQL版本 $mysqlInfo = @mysqli_get_server_info($connect); - if ((float)$mysqlInfo < 5.6) { - return $this->error('MySQL版本过低'); - } // 查询数据库名 + $database = false; $mysql_table = @mysqli_query($connect, 'SHOW DATABASES'); while ($row = @mysqli_fetch_assoc($mysql_table)) { if ($row['Database'] == $params['database']) { - return $this->error('数据库已存在,请勿重复安装'); + $database = true; + break; } } - $query = "CREATE DATABASE IF NOT EXISTS `" . $params['database'] . "` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;"; - if (!@mysqli_query($connect, $query)) { - return $this->error('数据库创建失败或已存在,请手动修改'); + if (!$database) { + $query = "CREATE DATABASE IF NOT EXISTS `" . $params['database'] . "` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;"; + if (!@mysqli_query($connect, $query)) { + return $this->error('数据库创建失败或已存在,请手动修改'); + } } Cache::set('mysqlInfo', $params);