1 | <?php |
||
10 | class DatabaseHandler |
||
11 | { |
||
12 | private $tableFields; |
||
|
|||
13 | private $dbHelperInstance; |
||
14 | private $dbConnection; |
||
15 | private $model; |
||
16 | |||
17 | /** |
||
18 | * This is a constructor; a default method that will be called automatically during class instantiation. |
||
19 | */ |
||
20 | public function __construct($modelClassName, $dbConn = null) |
||
30 | |||
31 | /** |
||
32 | * This method create a record and store it in a table row. |
||
33 | * |
||
34 | * @params associative array, string tablename |
||
35 | * |
||
36 | * @return bool true or false |
||
37 | */ |
||
38 | public function create($associative1DArray, $tableName, $dbConn = null) |
||
56 | |||
57 | /** |
||
58 | * This method runs the insertion query. |
||
59 | * |
||
60 | * @param $dbConn |
||
61 | * @param $tableName |
||
62 | * @param $associative1DArray |
||
63 | * |
||
64 | * @return bool true |
||
65 | */ |
||
66 | private function insertRecord($dbConn, $tableName, $associative1DArray) |
||
89 | |||
90 | /** |
||
91 | * This method updates any table by supplying 3 parameter. |
||
92 | * |
||
93 | * @params: $updateParams, $tableName, $associative1DArray |
||
94 | * |
||
95 | * @return bool true or false |
||
96 | */ |
||
97 | public function update(array $updateParams, $tableName, $associative1DArray, $dbConn = null) |
||
135 | |||
136 | /** |
||
137 | * This method retrieves record from a table. |
||
138 | * |
||
139 | * @params int id, string tableName |
||
140 | * |
||
141 | * @return array |
||
142 | */ |
||
143 | public static function read($id, $tableName, $dbConn = null) |
||
166 | |||
167 | /** |
||
168 | * This method deletes a record from a table row. |
||
169 | * |
||
170 | * @params int id, string tableName |
||
171 | * |
||
172 | * @return bool true or false |
||
173 | */ |
||
174 | public static function delete($id, $tableName, $dbConn = null) |
||
190 | |||
191 | /** |
||
192 | * This method checks if the magic setters array is the same as the table columns. |
||
193 | * |
||
194 | * @param array $tableColumn |
||
195 | * @param array $userSetterArray |
||
196 | * |
||
197 | * @return array $unexpectedFields |
||
198 | */ |
||
199 | public static function filterClassAttributes(array $tableColumn, array $userSetterArray) |
||
211 | |||
212 | /** |
||
213 | * This method returns sql query. |
||
214 | * |
||
215 | * @param $sql |
||
216 | * |
||
217 | * @return string |
||
218 | */ |
||
219 | public function prepareUpdateQuery($sql) |
||
229 | |||
230 | /** |
||
231 | * @param array $params |
||
232 | * @param $tableName |
||
233 | * @param $dbConn |
||
234 | * |
||
235 | * @throws EmptyArrayException |
||
236 | * |
||
237 | * @return bool |
||
238 | */ |
||
239 | public function findAndWhere($params, $tableName, $dbConn = null) |
||
262 | |||
263 | /** |
||
264 | * This method returns column fields of a particular table. |
||
265 | * |
||
266 | * @param $table |
||
267 | * @param $conn |
||
268 | * |
||
269 | * @return array |
||
270 | */ |
||
271 | public function getColumnNames($table, $dbConn = null) |
||
293 | } |
||
294 |
This check marks private properties in classes that are never used. Those properties can be removed.