Fix: player_list.php reivsed

This commit is contained in:
2019-07-11 10:45:27 +09:00
parent 251fc5adce
commit 4f02030c46
4 changed files with 56 additions and 154 deletions
+19 -10
View File
@@ -8,21 +8,23 @@ if ($has_file) {
class DBConnector
{
private $db_conn;
private $mysqli, $stmt, $query, $paramTypeList, $paramValueArray;
private $db_host, $db_user, $db_passwd, $db_name;
function __construct()
{
global $db_host, $db_user, $db_passwd, $db_name;
$this->stmt = null;
$this->paramTypeList = "";
$this->paramValueArray = null;
if (isset($db_host) && $db_host !== null) {
// echo "db_host variable\n";
$this->db_host = $db_host;
$this->db_user = $db_user;
$this->db_passwd = $db_passwd;
$this->db_name = $db_name;
} else {
// echo "no db_host variable\n";
$this->db_host = "localhost";
$this->db_user = "chocomae";
$this->db_passwd = "sEobMPuJ2A8KTfwU";
@@ -37,27 +39,29 @@ class DBConnector
public function connectDB()
{
// connect db
$this->db_conn = new mysqli($this->db_host, $this->db_user, $this->db_passwd, $this->db_name);
if ($this->db_conn->connect_error) {
$this->mysqli = new mysqli($this->db_host, $this->db_user, $this->db_passwd, $this->db_name);
// if ($this->mysqli->connect_error) {
if (mysqli_connect_errno()) {
return false;
}
$query = "USE chocomae";
$result = mysqli_query($this->db_conn, $query);
if (!$result)
$result = $this->mysqli->query($query);
if (!$result) {
return false;
}
return true;
}
public function closeDB()
{
if (isset($this->db_conn) || $this->db_conn === null) {
if (isset($this->mysqli) || $this->mysqli === null) {
return;
}
if ($this->db_conn->connect_error) {
$this->db_conn->close();
if ($this->mysqli->connect_error) {
$this->mysqli->close();
}
}
@@ -70,6 +74,11 @@ class DBConnector
$variables["name"] = $this->db_name;
return $variables;
}
public function getMysqli()
{
return $this->mysqli;
}
}
?>