diff options
-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 |