|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
|
|
3
|
|
|
namespace XoopsModules\Publisher; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Class TrelloDBController |
|
7
|
|
|
*/ |
|
8
|
|
|
class TrelloDBController |
|
9
|
|
|
{ |
|
10
|
|
|
/** @var \XoopsMySQLDatabase */ |
|
11
|
|
|
private $db; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* TrelloDBController constructor. |
|
15
|
|
|
* @param \XoopsMySQLDatabase $xoopsDb |
|
16
|
|
|
*/ |
|
17
|
|
|
public function __construct($xoopsDb) |
|
18
|
|
|
{ |
|
19
|
|
|
$this->db = $xoopsDb; |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @param string $query |
|
24
|
|
|
* @return mixed |
|
25
|
|
|
*/ |
|
26
|
|
|
public function runBaseQuery($query) |
|
27
|
|
|
{ |
|
28
|
|
|
$resultset = []; |
|
29
|
|
|
$result = $this->db->conn->query($query); |
|
30
|
|
|
if ($result->num_rows > 0) { |
|
31
|
|
|
while (null !== ($row = $result->fetch_assoc())) { |
|
32
|
|
|
$resultset[] = $row; |
|
33
|
|
|
} |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
return $resultset; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @param string $query |
|
41
|
|
|
* @param string $paramType |
|
42
|
|
|
* @param array $paramValueArray |
|
43
|
|
|
* @return mixed |
|
44
|
|
|
*/ |
|
45
|
|
|
public function runQuery($query, $paramType, $paramValueArray) |
|
46
|
|
|
{ |
|
47
|
|
|
/** @var mysqli_stmt $sql */ |
|
48
|
|
|
$sql = $this->db->conn->prepare($query); |
|
|
|
|
|
|
49
|
|
|
$this->bindQueryParams($sql, $paramType, $paramValueArray); |
|
50
|
|
|
$sql->execute(); |
|
51
|
|
|
$result = $sql->get_result(); |
|
52
|
|
|
|
|
53
|
|
|
if ($result->num_rows > 0) { |
|
54
|
|
|
while (null !== ($row = $result->fetch_assoc())) { |
|
55
|
|
|
$resultset[] = $row; |
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
if (!empty($resultset)) { |
|
60
|
|
|
return $resultset; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
return false; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* @param mysqli_stmt $sql |
|
|
|
|
|
|
68
|
|
|
* @param string $paramType |
|
69
|
|
|
* @param array $paramValueArray |
|
70
|
|
|
*/ |
|
71
|
|
|
public function bindQueryParams($sql, $paramType, $paramValueArray): void |
|
72
|
|
|
{ |
|
73
|
|
|
$paramValueReference = []; |
|
74
|
|
|
$paramValueReference[] = &$paramType; |
|
75
|
|
|
foreach ($paramValueArray as $i => $iValue) { |
|
76
|
|
|
$paramValueReference[] = &$iValue; |
|
77
|
|
|
} |
|
78
|
|
|
\call_user_func_array( |
|
79
|
|
|
[ |
|
80
|
|
|
$sql, |
|
81
|
|
|
'bind_param', |
|
82
|
|
|
], |
|
83
|
|
|
$paramValueReference |
|
84
|
|
|
); |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* @param string $query |
|
89
|
|
|
* @param string $paramType |
|
90
|
|
|
* @param array $paramValueArray |
|
91
|
|
|
*/ |
|
92
|
|
|
public function insert($query, $paramType, $paramValueArray): void |
|
93
|
|
|
{ |
|
94
|
|
|
/** @var mysqli_stmt $sql */ |
|
95
|
|
|
$sql = $this->db->conn->prepare($query); |
|
96
|
|
|
$this->bindQueryParams($sql, $paramType, $paramValueArray); |
|
97
|
|
|
$sql->execute(); |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
/** |
|
101
|
|
|
* @param string $query |
|
102
|
|
|
* @param string $paramType |
|
103
|
|
|
* @param array $paramValueArray |
|
104
|
|
|
*/ |
|
105
|
|
|
public function update($query, $paramType, $paramValueArray): void |
|
106
|
|
|
{ |
|
107
|
|
|
/** @var mysqli_stmt $sql */ |
|
108
|
|
|
$sql = $this->db->conn->prepare($query); |
|
109
|
|
|
$this->bindQueryParams($sql, $paramType, $paramValueArray); |
|
110
|
|
|
$sql->execute(); |
|
111
|
|
|
} |
|
112
|
|
|
} |
|
113
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.