-
Notifications
You must be signed in to change notification settings - Fork 2
/
database.php
63 lines (53 loc) · 1.33 KB
/
database.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
/**
* Created by PhpStorm.
* User: DiniX
* Date: 27-Jun-17
* Time: 9:47 AM
*/
class database{
private $host;
private $user;
private $password;
private $dbName;
private $connection;
private $results;
private static $dbInstance;
private function __construct()
{
}
public static function getInstance()
{
if (! self::$dbInstance){
self::$dbInstance = new self();
}
return self::$dbInstance;
}
function connect($host, $user, $password, $dbName){
$this->host = $host;
$this->user = $user;
$this->password = $password;
$this->dbName = $dbName;
$this->connection = mysqli_connect($this->host,$this->user,$this->password,$this->dbName);
}
public function closeConnection(){
mysqli_close($this->connection);
}
public function doQuery($sql){
$this->results = mysqli_query($this->connection, $sql) or die("Database access failed..!!");
}
public function loadObjList(){
$objArray = null;
if($this->results){
$objArray = mysqli_fetch_assoc($this->results);
}
return $objArray;
}
public function getConnection(){
return $this->connection;
}
public function getResult(){
return $this->results;
}
}
?>