blob: f2febac221f2257664574344a88f378dec7ada08 (
plain)
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
|
<?php
/**
* @package OpenCart
* @author Daniel Kerr
* @copyright Copyright (c) 2005 - 2017, OpenCart, Ltd. (https://www.opencart.com/)
* @license https://opensource.org/licenses/GPL-3.0
* @link https://www.opencart.com
*/
/**
* DB class
*/
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($adaptor, $hostname, $username, $password, $database, $port = NULL) {
$class = 'DB\\' . $adaptor;
if (class_exists($class)) {
$this->adaptor = new $class($hostname, $username, $password, $database, $port);
} else {
throw new \Exception('Error: Could not load database adaptor ' . $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);
}
/**
*
*
* @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();
}
}
|