1 | <?php |
||
4 | final class MysqliDatabase 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 | protected $mysqliResult; |
||
11 | |||
12 | public function __construct($config) |
||
32 | |||
33 | public function escape($string) |
||
37 | |||
38 | public function query($query, $params = []) |
||
39 | { |
||
40 | if (empty($query)) { |
||
41 | throw new \ErrorException('No query specified'); |
||
42 | } |
||
43 | /** |
||
44 | * For simplicity use statements even for simple queries. |
||
45 | */ |
||
46 | $this->stmt = $this->db->prepare($query); |
||
47 | $this->bindParams($params); |
||
48 | $this->stmt->execute(); |
||
49 | $this->setLastInsertId(); |
||
50 | return $this->stmt; |
||
51 | } |
||
52 | |||
53 | public function transaction($queries) |
||
54 | { |
||
55 | try { |
||
56 | $this->db->autocommit(false); |
||
57 | foreach ($queries as $item) { |
||
58 | if (!isset($item[0])) { |
||
59 | throw new \ErrorException('No query specified'); |
||
60 | } |
||
61 | $params = isset($item[1]) ? $item[1] : []; |
||
62 | $this->query($item[0], $params); |
||
63 | } |
||
64 | $this->db->commit(); |
||
65 | return true; |
||
66 | } catch (\Exception $e) { |
||
67 | $this->db->rollback(); |
||
68 | throw new \ErrorException($e->getMessage()); |
||
69 | } |
||
70 | } |
||
71 | |||
72 | public function numRows() |
||
83 | |||
84 | public function affectedRows() |
||
91 | |||
92 | public function getRows($query, $params = []) |
||
99 | |||
100 | public function getRow($query, $params = []) |
||
106 | |||
107 | public function getColumn($query, $params = [], $columnNumber = 0) |
||
114 | |||
115 | protected function bindParams($params = []) |
||
145 | |||
146 | protected function getDataType($variable) |
||
169 | |||
170 | protected function setLastInsertId() |
||
174 | } |
||
175 |
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: