summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.php5
-rw-r--r--connect.php3
-rw-r--r--db.php13
3 files changed, 15 insertions, 6 deletions
diff --git a/config.php b/config.php
index 700fe83..cae1286 100644
--- a/config.php
+++ b/config.php
@@ -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) {
diff --git a/db.php b/db.php
new file mode 100644
index 0000000..482b0ff
--- /dev/null
+++ b/db.php
@@ -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