-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathDatabase.php
More file actions
32 lines (26 loc) · 704 Bytes
/
Copy pathDatabase.php
File metadata and controls
32 lines (26 loc) · 704 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
<?php
/*
* class contains database management functions used all over the script
*/
class Database extends Common {
protected $db;
function __construct(){
$this->openDatabaseConnection();
}
function __destruct() {
$this->closeDatabaseConnection();
}
private function openDatabaseConnection()
{
$this->db = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
if ($this->db->connect_errno) {
echo "Failed to connect to MySQL: " . $this->db->connect_error;
die();
}
$this->db->set_charset(DB_CHARSET);
}
private function closeDatabaseConnection()
{
$this->db->close();
}
}