diff options
author | chai <chaifix@163.com> | 2022-03-22 21:17:14 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2022-03-22 21:17:14 +0800 |
commit | 9717df0608a46cb71fd696c70a25e6226a1e3c16 (patch) | |
tree | 288f1da91ace3c7f2ccc87b5ff4fa8d8af67a486 | |
parent | bb742acdd35fe84bb8ef2ff9007d01fcc902c682 (diff) |
* db config
-rw-r--r-- | config.php | 5 | ||||
-rw-r--r-- | connect.php | 3 | ||||
-rw-r--r-- | db.php | 13 |
3 files changed, 15 insertions, 6 deletions
@@ -2,11 +2,6 @@ class Config { - // 数据库连接 - public static $servername = "localhost"; - public static $username = "wod_dba"; - public static $password = ""; - public static $db_name = "musik"; // 数据库表格 public static $tb_album = "album"; diff --git a/connect.php b/connect.php index 8787da3..0a94c31 100644 --- a/connect.php +++ b/connect.php @@ -1,4 +1,5 @@ <?php require_once 'config.php'?> +<?php require_once 'db.php'?> <?php @@ -8,7 +9,7 @@ function execute_sql($sql) { global $conn; if($conn == NULL){ // 创建连接 - $conn = new mysqli(Config::$servername, Config::$username, Config::$password, Config::$db_name); + $conn = new mysqli(DBConfig::$servername, DBConfig::$username, DBConfig::$password, DBConfig::$db_name); // 检测连接 if ($conn->connect_error) { @@ -0,0 +1,13 @@ +<?php + +class DBConfig +{ + // 数据库连接 + public static $servername = "localhost"; + public static $username = "wod_dba"; + public static $password = ""; + public static $db_name = "musik"; + +} + +?>
\ No newline at end of file |