-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDB.php
88 lines (78 loc) · 1.42 KB
/
DB.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
namespace voinmerk\botapp;
class DB {
private $adaptor;
/**
* Constructor
*
* @param string $adaptor
* @param string $hostname
* @param string $username
* @param string $password
* @param string $database
* @param int $port
*
*/
public function __construct($db) {
$class = 'voinmerk\\botapp\\db\\' . $db['adaptor'];
if (class_exists($class)) {
$this->adaptor = new $class($db['hostname'], $db['username'], $db['password'], $db['database'], $db['port']);
} else {
throw new \Exception('Error: Could not load database adaptor ' . $db['adaptor'] . '!');
}
}
/**
*
*
* @param string $sql
*
* @return array
*/
public function query($sql) {
return $this->adaptor->query($sql);
}
/**
*
*
* @param string $value
*
* @return string
*/
public function escape($value) {
return $this->adaptor->escape($value);
}
/**
*
*
* @param string $value
*
* @return string
*/
public function escapeString($value) {
return "'" . $this->adaptor->escape($value) . "'";
}
/**
*
*
* @return int
*/
public function countAffected() {
return $this->adaptor->countAffected();
}
/**
*
*
* @return int
*/
public function getLastId() {
return $this->adaptor->getLastId();
}
/**
*
*
* @return bool
*/
public function connected() {
return $this->adaptor->connected();
}
}