-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDbhandler.class.php
More file actions
39 lines (32 loc) · 833 Bytes
/
Dbhandler.class.php
File metadata and controls
39 lines (32 loc) · 833 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
34
35
36
37
38
39
<?php
class Dbhandler {
private $host;
private $user;
private $pass;
private $db;
public $conn;
public function __construct() {
$this->connect();
}
private function connect() {
// default XAMPP credentials
$this->host = "127.0.0.1";
$this->user = "root";
$this->pass = "";
$this->db = "ogtech";
// connect to db
$this->conn = new mysqli($this->host, $this->user, $this->pass, $this->db);
return $this->conn;
/* check connection */
if (!$this->conn)
die("Connection failed: " . mysqli_connect_error());
}
public function conn() {
// connect to db
$this->conn = new mysqli("127.0.0.1", "root", "", "ogtech");
return $this->conn;
/* check connection */
if (!$this->conn)
die("Connection failed: " . mysqli_connect_error());
}
}