-
Notifications
You must be signed in to change notification settings - Fork 0
/
database.class.php
42 lines (32 loc) · 1.05 KB
/
database.class.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
# @ Desc: Programmed by Neorm 2O16/2O17
# @ Contact: https://www.facebook.com/gonniy.officiel
#=========| Database Diagram |=========#
# id, username, password, email, level #
#======================================#
class Database {
protected $_dbHost; // database hostname
protected $_dbName; // database name
protected $_dbUser; // database user
protected $_dbPass; // database password
public $handler; // the holder
// defined the infos of the database
public function __construct($host, $name, $user, $pass = null) {
$this->_dbHost = $host;
$this->_dbName = $name;
$this->_dbUser = $user;
$this->_dbPass = $pass;
}
// connect with the database
final public function connect() {
try{
$this->handler = new PDO('mysql:host='. $this->_dbHost .';dbname='. $this->_dbName,$this->_dbUser,$this->_dbPass);
}catch(PDOException $e) {
echo 'Error connecting: '.$e->getMessage();
}
}
// clear the database if we done of it
public function __deconstruct() {
unset($this->handler);
}
}