-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdatabase.php
More file actions
33 lines (27 loc) · 956 Bytes
/
database.php
File metadata and controls
33 lines (27 loc) · 956 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
class DataBase {
protected $servername;
protected $username;
protected $password;
protected $dbname;
function __construct() {
$this->servername = "localhost";
$this->username = "root";
$this->password = "";
$this->dbname = "hero_game";
$this->conn = $this->connectDB($this->servername, $this->username, $this->password, $this->dbname);
}
function __destruct() {
$this->conn->close();
}
private function connectDB($servername, $username, $password, $dbname){
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
return $conn;
}
public function queryRun($query){
return $this->conn->query($query);
}
}