diff --git a/app/install/controller/Index.php b/app/install/controller/Index.php index 67b3158..a946e86 100644 --- a/app/install/controller/Index.php +++ b/app/install/controller/Index.php @@ -78,9 +78,17 @@ class Index // 验证失败 输出错误信息 return to_assign(1, $e->getError()); } - $dbName = $data['DB_NAME']; - // 连接数据库 - $link = @new mysqli("{$data['DB_HOST']}:{$data['DB_PORT']}", $data['DB_USER'], $data['DB_PWD']); + $dbName = $data['DB_NAME']; + //验证表是否存在 + try { + // 连接数据库 + $link = @new mysqli("{$data['DB_HOST']}:{$data['DB_PORT']}", $data['DB_USER'], $data['DB_PWD']); + } catch (\Exception $e) { + // 这是进行异常捕获,创建数据库 + $error = $e->getMessage(); + return to_assign(1, '数据库链接失败:' . $error);die; + } + // 获取错误信息 $error = $link->connect_error; if (!is_null($error)) { @@ -93,12 +101,22 @@ class Index if ($link->server_info < 5.0) { return to_assign(1, '请将您的mysql升级到5.0以上');die; } - // 创建数据库并选中 - if (!$link->select_db($dbName)) { - //创建数据库 - $sql = "CREATE DATABASE IF NOT EXISTS `{$dbName}` DEFAULT CHARACTER SET utf8mb4"; + //验证表是否存在 + try { + // 这里是主体代码 + $isDB=$link->query('SHOW TABLES LIKE '."'".$dbName."'"); + if(!$isDB){ + //创建数据库并选中 + $sql = "CREATE DATABASE IF NOT EXISTS `{$dbName}` DEFAULT CHARACTER SET utf8mb4"; + $link->query($sql); + } + } catch (\Exception $e) { + // 这是进行异常捕获,创建数据库并选中 + $error = $e->getMessage(); + $sql = "CREATE DATABASE IF NOT EXISTS `{$dbName}` DEFAULT CHARACTER SET utf8mb4"; $link->query($sql); - } + } + $link->select_db($dbName); // 导入sql数据并创建表 $oa_sql = file_get_contents(CMS_ROOT . '/app/install/data/gouguoa.sql'); diff --git a/app/install/view/index/step3.html b/app/install/view/index/step3.html index 39115bd..11a70d0 100644 --- a/app/install/view/index/step3.html +++ b/app/install/view/index/step3.html @@ -18,12 +18,13 @@ background: url("{__IMG__}/bg_pattern.png"), -webkit-linear-gradient(to left, #34a853, #4285f4); background: url("{__IMG__}/bg_pattern.png"), linear-gradient(to left, #34a853, #4285f4); } + .layui-form-item{margin-bottom:10px;} + h3{padding-bottom:10px; font-weight:600;} -
勾股OA安装
+
勾股OA安装
@@ -32,98 +33,85 @@
  • v{:CMS_VERSION}
  • -
    +
    -

    数据库配置


    +

    数据库配置

    - +
    固定为mysql,不可更改
    - +
    数据库服务器地址,一般为127.0.0.1
    - +
    数据库端口,一般为3306
    - +
    系统数据库名,必须包含字母,不能有"-"等特殊符号
    - +
    连接数据库的用户名
    - +
    连接数据库的密码
    - +
    建议使用默认,同一个数据库安装多个系统时需更改,否则会覆盖

    -

    管理员配置


    +

    管理员配置

    -
    - +
    +
    -
    -
    -
    - +
    +
    -
    - +
    +
    -
    - -