-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb.php
More file actions
executable file
·93 lines (82 loc) · 2.76 KB
/
db.php
File metadata and controls
executable file
·93 lines (82 loc) · 2.76 KB
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
89
90
91
92
93
<?php
class plugins_paypal_db
{
/**
* @param $config
* @$params bool $data
* @return mixed|null
* @throws Exception
*/
public function fetchData($config, $params = false)
{
$sql = '';
if (is_array($config)) {
if ($config['context'] === 'all') {
switch ($config['type']) {
case 'data':
$sql = 'SELECT hp.* FROM mc_paypal AS hp';
break;
}
return $sql ? component_routing_db::layer()->fetchAll($sql, $params) : null;
}
elseif ($config['context'] === 'one') {
switch ($config['type']) {
case 'root':
$sql = 'SELECT * FROM mc_paypal ORDER BY id_paypal DESC LIMIT 0,1';
break;
case 'history':
$sql = 'SELECT * FROM mc_paypal_history WHERE order_h = :order_h';
break;
case 'lastHistory':
$sql = 'SELECT * FROM mc_paypal_history ORDER BY id_paypal_h DESC LIMIT 0,1';
break;
}
return $sql ? component_routing_db::layer()->fetch($sql, $params) : null;
}
}
}
/**
* @param $config
* @param array $params
* @throws Exception
*/
public function insert($config, $params = array())
{
if (is_array($config)) {
$sql = '';
switch ($config['type']) {
case 'newConfig':
$sql = 'INSERT INTO mc_paypal (clientId,clientSecret,mode,log)
VALUE(:clientId,:clientSecret,:mode,:log)';
break;
case 'history':
$sql = 'INSERT INTO mc_paypal_history (order_h,status_h) VALUE(:order_h,:status_h)';
break;
}
if($sql !== '') component_routing_db::layer()->insert($sql,$params);
}
}
/**
* @param $config
* @param array $params
* @throws Exception
*/
public function update($config, $params = array())
{
if (is_array($config)) {
$sql = '';
switch ($config['type']) {
case 'config':
$sql = 'UPDATE mc_paypal
SET clientId=:clientId,
clientSecret=:clientSecret,
mode=:mode,
log=:log
WHERE id_paypal=:id';
break;
}
if($sql !== '') component_routing_db::layer()->update($sql,$params);
}
}
}
?>