1 | <?php |
||
4 | final class PdoDatabase extends \WebServCo\Framework\AbstractDatabase implements |
||
5 | \WebServCo\Framework\Interfaces\DatabaseInterface |
||
6 | { |
||
7 | use \WebServCo\Framework\Traits\DatabaseTrait; |
||
8 | use \WebServCo\Framework\Traits\MysqlDatabaseTrait; |
||
9 | |||
10 | public function __construct($config) |
||
34 | |||
35 | public function escape($string) |
||
39 | |||
40 | public function query($query, $params = []) |
||
41 | { |
||
42 | if (empty($query)) { |
||
43 | throw new \ErrorException('No query specified'); |
||
44 | } |
||
45 | |||
46 | if (!empty($params)) { |
||
47 | $this->stmt = $this->db->prepare($query); |
||
48 | $this->bindParams($params); |
||
49 | $this->stmt->execute(); |
||
50 | } else { |
||
51 | $this->stmt = $this->db->query($query); |
||
52 | } |
||
53 | $this->setLastInsertId(); |
||
54 | return $this->stmt; |
||
55 | } |
||
56 | |||
57 | public function transaction($queries) |
||
58 | { |
||
59 | try { |
||
60 | $this->db->beginTransaction(); |
||
61 | foreach ($queries as $item) { |
||
62 | if (!isset($item[0])) { |
||
63 | throw new \ErrorException('No query specified'); |
||
64 | } |
||
65 | $params = isset($item[1]) ? $item[1] : []; |
||
66 | $this->query($item[0], $params); |
||
67 | } |
||
68 | $this->db->commit(); |
||
69 | return true; |
||
70 | } catch (\Exception $e) { |
||
71 | $this->db->rollBack(); |
||
72 | throw new \ErrorException($e->getMessage()); |
||
73 | } |
||
74 | } |
||
75 | |||
76 | public function numRows() |
||
87 | |||
88 | public function affectedRows() |
||
95 | |||
96 | public function getRows($query, $params = []) |
||
102 | |||
103 | public function getRow($query, $params = []) |
||
108 | |||
109 | public function getColumn($query, $params = [], $columnNumber = 0) |
||
114 | |||
115 | protected function bindParams($data) |
||
135 | |||
136 | protected function getDataType($variable) |
||
161 | |||
162 | protected function setLastInsertId() |
||
166 | } |
||
167 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: