-
Notifications
You must be signed in to change notification settings - Fork 1
/
dbs.php
61 lines (41 loc) · 1.09 KB
/
dbs.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
<?php
class myDB{
public $con;
private static $instance;
protected $HOST=NULL;
protected $USER=NULL;
protected $PASS=NULL;
protected $DBS=NULL;
public function __construct($user, $pwd, $dbs, $host='localhost'){
$this->HOST = $host;
$this->USER = $user; $this->PASS = $pwd; $this->DBS = $dbs;
try{
$this->con = new PDO("mysql:host=".$this->HOST.";dbname=".$this->DBS, $this->USER, $this->PASS);
$this->con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$this->con->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_BOTH);
}catch(PDOException $e){
$this->con = NULL;
print "Error!: " . $e->getMessage() . "<br/>";
}
}
public function getObj(){
return $this->con;
}
/*
public function showCred(){
echo "U: " . $this->USER; echo " <br>";
echo "P: " . $this->PASS; echo " <br>";
echo "D: " . $this->DBS; echo " <br>";
}
*/
/*
public static function getObjInst(){
if( !isset(self::$instance) ){
$object = __CLASS__;
self::$instance = new $object();
}
return self::$instance;
}
*/
}
?>