@@ -83,6 +83,7 @@ discard block |
||
83 | 83 | /** |
84 | 84 | * getTableName() |
85 | 85 | * |
86 | + * @param string $connection |
|
86 | 87 | * @return string |
87 | 88 | */ |
88 | 89 | protected function getTableName($connection) |
@@ -123,7 +124,7 @@ discard block |
||
123 | 124 | * @param $tablename |
124 | 125 | * @param $con |
125 | 126 | * |
126 | - * @return bool |
|
127 | + * @return boolean|null |
|
127 | 128 | */ |
128 | 129 | public function checkTableExist($table, $con=NULL) |
129 | 130 | { |
@@ -138,7 +139,7 @@ discard block |
||
138 | 139 | /** |
139 | 140 | * checkTableName Return the table name |
140 | 141 | * |
141 | - * @param $tablename |
|
142 | + * @param string $tablename |
|
142 | 143 | * @param $con |
143 | 144 | * |
144 | 145 | * @return string |
@@ -159,7 +160,7 @@ discard block |
||
159 | 160 | * checkColumn Check if column exist in table |
160 | 161 | * |
161 | 162 | * @param $tableName |
162 | - * @param $columnName |
|
163 | + * @param string $columnName |
|
163 | 164 | * @param $con |
164 | 165 | * |
165 | 166 | * @return string |
@@ -268,6 +269,7 @@ discard block |
||
268 | 269 | /** |
269 | 270 | * selectAllQuery |
270 | 271 | * |
272 | + * @param string $tableName |
|
271 | 273 | * @return string |
272 | 274 | */ |
273 | 275 | public function selectAllQuery($tableName) |
@@ -327,6 +329,9 @@ discard block |
||
327 | 329 | /** |
328 | 330 | * selectQuery |
329 | 331 | * |
332 | + * @param string $tableName |
|
333 | + * @param string $fields |
|
334 | + * @param string $connection |
|
330 | 335 | * @return string |
331 | 336 | */ |
332 | 337 | public static function selectQuery($tableName, $fields, $data, $condition, $connection) |
@@ -360,6 +365,7 @@ discard block |
||
360 | 365 | /** |
361 | 366 | * insertQuery |
362 | 367 | * |
368 | + * @param string $tableName |
|
363 | 369 | * @return string |
364 | 370 | */ |
365 | 371 | public function insertQuery($tableName) |
@@ -373,6 +379,7 @@ discard block |
||
373 | 379 | /** |
374 | 380 | * updateQuery |
375 | 381 | * |
382 | + * @param string $tableName |
|
376 | 383 | * @return string |
377 | 384 | */ |
378 | 385 | public function updateQuery($tableName, $id) |
@@ -387,7 +394,8 @@ discard block |
||
387 | 394 | * query($query, $dbCOnnection) |
388 | 395 | * Raw sql query |
389 | 396 | * |
390 | - * @return object |
|
397 | + * @param string $query |
|
398 | + * @return GetData |
|
391 | 399 | */ |
392 | 400 | public function query($query, $con = NULL) |
393 | 401 | { |
@@ -125,11 +125,11 @@ discard block |
||
125 | 125 | * |
126 | 126 | * @return bool |
127 | 127 | */ |
128 | - public function checkTableExist($table, $con=NULL) |
|
128 | + public function checkTableExist($table, $con = NULL) |
|
129 | 129 | { |
130 | 130 | $connection = $this->checkConnection($con); |
131 | 131 | $query = $connection->query("SELECT 1 FROM {$table} LIMIT 1"); |
132 | - if($query !== false) |
|
132 | + if ($query !== false) |
|
133 | 133 | { |
134 | 134 | return true; |
135 | 135 | } |
@@ -143,12 +143,12 @@ discard block |
||
143 | 143 | * |
144 | 144 | * @return string |
145 | 145 | */ |
146 | - protected static function checkTableName($tableName, $con=NULL) |
|
146 | + protected static function checkTableName($tableName, $con = NULL) |
|
147 | 147 | { |
148 | 148 | $connection = self::checkConnection($con); |
149 | 149 | |
150 | 150 | $query = $connection->query("SELECT 1 FROM {$tableName} LIMIT 1"); |
151 | - if($query !== false) |
|
151 | + if ($query !== false) |
|
152 | 152 | { |
153 | 153 | return $tableName; |
154 | 154 | } |
@@ -164,13 +164,13 @@ discard block |
||
164 | 164 | * |
165 | 165 | * @return string |
166 | 166 | */ |
167 | - protected static function checkColumn($tableName, $columnName, $con=NULL) |
|
167 | + protected static function checkColumn($tableName, $columnName, $con = NULL) |
|
168 | 168 | { |
169 | 169 | $connection = self::checkConnection($con); |
170 | 170 | |
171 | 171 | $result = $connection->prepare("SELECT {$columnName} FROM {$tableName}"); |
172 | 172 | $result->execute(); |
173 | - if (! $result->columnCount()) |
|
173 | + if ( ! $result->columnCount()) |
|
174 | 174 | { |
175 | 175 | throw new ColumnNotExistExeption(); |
176 | 176 | } |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | { |
195 | 195 | $counter++; |
196 | 196 | $insertQuery .= self::sanitize($key); |
197 | - if($arraySize > $counter) |
|
197 | + if ($arraySize > $counter) |
|
198 | 198 | $insertQuery .= ", "; |
199 | 199 | } |
200 | 200 | return $insertQuery; |
@@ -216,8 +216,8 @@ discard block |
||
216 | 216 | foreach ($data as $key => $value) |
217 | 217 | { |
218 | 218 | $counter++; |
219 | - $insertQuery .= "'".self::sanitize($value) ."'"; |
|
220 | - if($arraySize > $counter) |
|
219 | + $insertQuery .= "'".self::sanitize($value)."'"; |
|
220 | + if ($arraySize > $counter) |
|
221 | 221 | $insertQuery .= ", "; |
222 | 222 | } |
223 | 223 | return $insertQuery; |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | { |
241 | 241 | $counter++; |
242 | 242 | $columnName = self::checkColumn($tableName, self::sanitize($key)); |
243 | - $updateQuery .= $columnName ." = '".self::sanitize($value)."'"; |
|
243 | + $updateQuery .= $columnName." = '".self::sanitize($value)."'"; |
|
244 | 244 | if ($arraySize > $counter) |
245 | 245 | { |
246 | 246 | $updateQuery .= ", "; |
@@ -291,10 +291,10 @@ discard block |
||
291 | 291 | { |
292 | 292 | $counter++; |
293 | 293 | $columnName = self::checkColumn($tableName, self::sanitize($key)); |
294 | - $where .= $tableName.'.'.$columnName ." = '".self::sanitize($value)."'"; |
|
294 | + $where .= $tableName.'.'.$columnName." = '".self::sanitize($value)."'"; |
|
295 | 295 | if ($arraySize > $counter) |
296 | 296 | { |
297 | - $where .= " " . $condition . " "; |
|
297 | + $where .= " ".$condition." "; |
|
298 | 298 | } |
299 | 299 | } |
300 | 300 | } else { |
@@ -310,14 +310,14 @@ discard block |
||
310 | 310 | $counter = 0; |
311 | 311 | $arraySize = count($data); |
312 | 312 | |
313 | - foreach ( $data as $key => $value ) |
|
313 | + foreach ($data as $key => $value) |
|
314 | 314 | { |
315 | 315 | $counter++; |
316 | 316 | $columnName = self::checkColumn($tableName, self::sanitize($key)); |
317 | - $where .= $columnName ." LIKE '%".self::sanitize($value)."%'"; |
|
318 | - if ( $arraySize > $counter ) |
|
317 | + $where .= $columnName." LIKE '%".self::sanitize($value)."%'"; |
|
318 | + if ($arraySize > $counter) |
|
319 | 319 | { |
320 | - $where .= " " . $condition . " "; |
|
320 | + $where .= " ".$condition." "; |
|
321 | 321 | } |
322 | 322 | } |
323 | 323 | |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | try |
338 | 338 | { |
339 | 339 | $arraySize = count($data); |
340 | - if( $arraySize > 1 && $condition == NULL) |
|
340 | + if ($arraySize > 1 && $condition == NULL) |
|
341 | 341 | { |
342 | 342 | $query = "Please Supply the condition"; |
343 | 343 | } |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | } elseif ($condition === 'LIKE') { |
349 | 349 | $columnName = self::whereLikeClause($tableName, $data, $condition); |
350 | 350 | } |
351 | - $query = "SELECT $fields FROM $tableName WHERE $columnName"; |
|
351 | + $query = "SELECT $fields FROM $tableName WHERE $columnName"; |
|
352 | 352 | } |
353 | 353 | } catch (PDOException $e) { |
354 | 354 | $query = $e->getMessage(); |
@@ -23,16 +23,16 @@ discard block |
||
23 | 23 | $output = ""; |
24 | 24 | $i = 0; |
25 | 25 | |
26 | - if (! isset($data[0]) || $data[1]->REFERENCED_TABLE_NAME !== null) { |
|
27 | - foreach($data as $key => $value) { |
|
26 | + if ( ! isset($data[0]) || $data[1]->REFERENCED_TABLE_NAME !== null) { |
|
27 | + foreach ($data as $key => $value) { |
|
28 | 28 | if ( ! empty($value->REFERENCED_TABLE_NAME)) { |
29 | 29 | $output .= ' JOIN '.$value->REFERENCED_TABLE_NAME; |
30 | 30 | } |
31 | 31 | } |
32 | - foreach($data as $key => $value) { |
|
32 | + foreach ($data as $key => $value) { |
|
33 | 33 | $i++; |
34 | 34 | $whereAnd = $i > 1 ? 'AND' : 'WHERE'; |
35 | - if ( empty($value->REFERENCED_TABLE_NAME)) { |
|
35 | + if (empty($value->REFERENCED_TABLE_NAME)) { |
|
36 | 36 | $value->REFERENCED_TABLE_NAME = self::getTableName($connection); |
37 | 37 | $value->REFERENCED_COLUMN_NAME = $value->COLUMN_NAME; |
38 | 38 | } |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | } else if ($joinClause == false && $data !== null) { |
59 | 59 | $query .= ' WHERE '.$columnName; |
60 | 60 | } else { |
61 | - $query .= ($data === null) ? $joinClause : $joinClause .' AND '.$columnName; |
|
61 | + $query .= ($data === null) ? $joinClause : $joinClause.' AND '.$columnName; |
|
62 | 62 | } |
63 | 63 | return $query; |
64 | 64 | } |