-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDatabase.php
More file actions
27 lines (24 loc) · 726 Bytes
/
Database.php
File metadata and controls
27 lines (24 loc) · 726 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
<?php
class Database {
private $host = 'localhost';
private $dbname = 'tms_db';
private $username = 'root';
private $password = '';
private $conn;
public function __construct() {
try {
$this->conn = new mysqli($this->host, $this->username, $this->password, $this->dbname);
// Check connection
if ($this->conn->connect_error) {
throw new Exception("Connection failed: " . $this->conn->connect_error);
}
} catch (Exception $e) {
// Handle the exception
die("Connection failed: " . $e->getMessage());
}
}
public function getConnection() {
return $this->conn;
}
}
?>