1 | <?php |
||
9 | abstract class AbstractStorage implements StorageInterface |
||
10 | { |
||
11 | /** |
||
12 | * @var PDO |
||
13 | */ |
||
14 | private $connection; |
||
15 | |||
16 | /** |
||
17 | * @var string |
||
18 | */ |
||
19 | private $tableName; |
||
20 | |||
21 | /** |
||
22 | * @var string |
||
23 | */ |
||
24 | private $idColumn; |
||
25 | |||
26 | /** |
||
27 | * @param PDO $connection |
||
28 | * @param string $tableName |
||
29 | * @param string $idColumn |
||
30 | */ |
||
31 | public function __construct(PDO $connection, $tableName, $idColumn = 'id') |
||
37 | |||
38 | /** |
||
39 | * @param PDO $connection |
||
40 | * |
||
41 | * @return self |
||
42 | */ |
||
43 | public function setConnection(PDO $connection) |
||
48 | |||
49 | /** |
||
50 | * @return PDO |
||
51 | */ |
||
52 | public function getConnection() |
||
56 | |||
57 | /** |
||
58 | * @param string $tableName |
||
59 | * |
||
60 | * @return self |
||
61 | */ |
||
62 | public function setTableName($tableName) |
||
67 | |||
68 | /** |
||
69 | * @return string |
||
70 | */ |
||
71 | public function getTableName() |
||
75 | |||
76 | /** |
||
77 | * @param string $idColumn |
||
78 | * |
||
79 | * @return self |
||
80 | */ |
||
81 | public function setIdColumn($idColumn) |
||
86 | |||
87 | /** |
||
88 | * @return string |
||
89 | */ |
||
90 | public function getIdColumn() |
||
94 | |||
95 | /** |
||
96 | * @return int |
||
97 | */ |
||
98 | public function getNumberOfRows() |
||
105 | |||
106 | /** |
||
107 | * @param string $sql |
||
108 | * @param array $params |
||
109 | * |
||
110 | * @return array |
||
111 | */ |
||
112 | private function selectQuery($sql, array $params = array()) |
||
119 | |||
120 | /** |
||
121 | * @param array $values |
||
122 | */ |
||
123 | public function insert(array $values) |
||
140 | |||
141 | /** |
||
142 | * @param array $columns |
||
143 | * @param string $placeholderPrefix |
||
144 | * |
||
145 | * @return array |
||
146 | */ |
||
147 | private function columnsToPlaceholders(array $columns, $placeholderPrefix = '') |
||
157 | |||
158 | public function find($id) |
||
177 | |||
178 | public function findAllBy(array $conditions = array(), $limit = null, $offset = 0) |
||
194 | |||
195 | private function assembleEquality(array $conditions, $placeholderPrefix = '') |
||
206 | |||
207 | /** |
||
208 | * @param array $conditions |
||
209 | * @param array $values |
||
210 | */ |
||
211 | public function updateWhere(array $conditions, array $values) |
||
236 | |||
237 | public function findOneBy(array $conditions) |
||
247 | |||
248 | public function exists(array $conditions) |
||
253 | |||
254 | /** |
||
255 | * @param array $conditions |
||
256 | */ |
||
257 | public function deleteWhere(array $conditions) |
||
271 | } |
||
272 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.