-
Notifications
You must be signed in to change notification settings - Fork 0
/
DBConfig.php
42 lines (30 loc) · 1008 Bytes
/
DBConfig.php
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
40
41
42
<?php
class DBConnection {
private static $instance;
private $con;
private $dbCon;
private $dbName;
private $dbPassword;
private $dbUserName;
private $dbServer;
private function __construct () {
$this->dbServer = "localhost"; // Server Name
$this->dbUserName = "root"; // Username
$this->dbPassword = ""; // Password
$this->dbName = "loginapp"; // DB Name
$this->con = mysqli_connect($this->dbServer,$this->dbUserName, $this->dbPassword) or die( "Unable to connect");
$this->dbCon = mysqli_select_db($this->con,$this->dbName) or die( "Unable to select database");
}
/*This function will return the instance of DB*/
public static function getInstance () {
if (DBConnection::$instance == null) {
DBConnection::$instance = new DBConnection();
}
return DBConnection::$instance;
}
public function getConnection (){
return $this->con;
}
}
//print_r( DBConnection::getInstance()-> getConnection());
?>