DB connect 내용에 port 번호 추가

This commit is contained in:
2026-07-06 17:20:31 +09:00
parent 51b9a99f95
commit 1ea9e64667
3 changed files with 8 additions and 4 deletions
+5 -3
View File
@@ -9,11 +9,11 @@ if ($has_file) {
class DBConnector class DBConnector
{ {
private $mysqli, $stmt, $query, $paramTypeList, $paramValueArray; private $mysqli, $stmt, $query, $paramTypeList, $paramValueArray;
private $db_host, $db_user, $db_passwd, $db_name; private $db_host, $db_user, $db_passwd, $db_name, $db_port;
function __construct() function __construct()
{ {
global $db_host, $db_user, $db_passwd, $db_name; global $db_host, $db_user, $db_passwd, $db_name, $db_port;
$this->stmt = null; $this->stmt = null;
$this->paramTypeList = ""; $this->paramTypeList = "";
@@ -24,11 +24,13 @@ class DBConnector
$this->db_user = $db_user; $this->db_user = $db_user;
$this->db_passwd = $db_passwd; $this->db_passwd = $db_passwd;
$this->db_name = $db_name; $this->db_name = $db_name;
$this->db_port = isset($db_port) ? $db_port : 3306;
} else { } else {
$this->db_host = "localhost"; $this->db_host = "localhost";
$this->db_user = "chocomae"; $this->db_user = "chocomae";
$this->db_passwd = "sEobMPuJ2A8KTfwU"; $this->db_passwd = "sEobMPuJ2A8KTfwU";
$this->db_name = "chocomae"; $this->db_name = "chocomae";
$this->db_port = 3306;
} }
} }
@@ -39,7 +41,7 @@ class DBConnector
public function connectDB() public function connectDB()
{ {
// connect db // connect db
$this->mysqli = new mysqli($this->db_host, $this->db_user, $this->db_passwd, $this->db_name); $this->mysqli = new mysqli($this->db_host, $this->db_user, $this->db_passwd, $this->db_name, $this->db_port);
// if ($this->mysqli->connect_error) { // if ($this->mysqli->connect_error) {
if (mysqli_connect_errno()) { if (mysqli_connect_errno()) {
return false; return false;
@@ -4,5 +4,6 @@ $db_host = "localhost";
$db_user = "chocomae"; $db_user = "chocomae";
$db_passwd = "sEobMPuJ2A8KTfwU"; $db_passwd = "sEobMPuJ2A8KTfwU";
$db_name = "chocomae"; $db_name = "chocomae";
$db_port = 3306;
?> ?>
+2 -1
View File
@@ -10,10 +10,11 @@ if($hasServiceDBSetting == true) {
$db_passwd = "Fr12nds95"; $db_passwd = "Fr12nds95";
$db_name = "jisangs"; $db_name = "jisangs";
} }
if (!isset($db_port)) $db_port = 3306;
// connect db // connect db
$db_conn = new mysqli($db_host, $db_user, $db_passwd, $db_name); $db_conn = new mysqli($db_host, $db_user, $db_passwd, $db_name, $db_port);
if ($db_conn->connect_error) { if ($db_conn->connect_error) {
set_error_message("DB connection failed."); set_error_message("DB connection failed.");
send_result_fail(); send_result_fail();