@@ -13,7 +13,6 @@ |
||
13 | 13 | use PDOException; |
14 | 14 | use Ibonly\PotatoORM\DatabaseQueryInterface; |
15 | 15 | use Ibonly\PotatoORM\ColumnNotExistExeption; |
16 | -use Ibonly\PotatoORM\InvalidConnectionException; |
|
17 | 16 | use Ibonly\PotatoORM\TableDoesNotExistException; |
18 | 17 | |
19 | 18 | class DatabaseQuery implements DatabaseQueryInterface |
@@ -82,6 +82,7 @@ discard block |
||
82 | 82 | /** |
83 | 83 | * getTableName() |
84 | 84 | * |
85 | + * @param string $connection |
|
85 | 86 | * @return string |
86 | 87 | */ |
87 | 88 | protected function getTableName($connection) |
@@ -122,7 +123,7 @@ discard block |
||
122 | 123 | * @param $tablename |
123 | 124 | * @param $con |
124 | 125 | * |
125 | - * @return bool |
|
126 | + * @return boolean|null |
|
126 | 127 | */ |
127 | 128 | public function checkTableExist($table, $con=NULL) |
128 | 129 | { |
@@ -137,7 +138,7 @@ discard block |
||
137 | 138 | /** |
138 | 139 | * checkTableName Return the table name |
139 | 140 | * |
140 | - * @param $tablename |
|
141 | + * @param string $tablename |
|
141 | 142 | * @param $con |
142 | 143 | * |
143 | 144 | * @return string |
@@ -158,7 +159,7 @@ discard block |
||
158 | 159 | * checkColumn Check if column exist in table |
159 | 160 | * |
160 | 161 | * @param $tableName |
161 | - * @param $columnName |
|
162 | + * @param string $columnName |
|
162 | 163 | * @param $con |
163 | 164 | * |
164 | 165 | * @return string |
@@ -315,6 +316,9 @@ discard block |
||
315 | 316 | /** |
316 | 317 | * selectQuery |
317 | 318 | * |
319 | + * @param string $tableName |
|
320 | + * @param string $fields |
|
321 | + * @param string $connection |
|
318 | 322 | * @return string |
319 | 323 | */ |
320 | 324 | public static function selectQuery($tableName, $fields, $data, $condition, $connection) |
@@ -342,6 +346,7 @@ discard block |
||
342 | 346 | /** |
343 | 347 | * insertQuery |
344 | 348 | * |
349 | + * @param string $tableName |
|
345 | 350 | * @return string |
346 | 351 | */ |
347 | 352 | public function insertQuery($tableName) |
@@ -358,6 +363,7 @@ discard block |
||
358 | 363 | /** |
359 | 364 | * updateQuery |
360 | 365 | * |
366 | + * @param string $tableName |
|
361 | 367 | * @return string |
362 | 368 | */ |
363 | 369 | public function updateQuery($tableName) |
@@ -375,7 +381,8 @@ discard block |
||
375 | 381 | * query($query, $dbCOnnection) |
376 | 382 | * Raw sql query |
377 | 383 | * |
378 | - * @return object |
|
384 | + * @param string $query |
|
385 | + * @return GetData |
|
379 | 386 | */ |
380 | 387 | public function query($query, $con = NULL) |
381 | 388 | { |
@@ -124,11 +124,11 @@ discard block |
||
124 | 124 | * |
125 | 125 | * @return bool |
126 | 126 | */ |
127 | - public function checkTableExist($table, $con=NULL) |
|
127 | + public function checkTableExist($table, $con = NULL) |
|
128 | 128 | { |
129 | 129 | $connection = $this->checkConnection($con); |
130 | 130 | $query = $connection->query("SELECT 1 FROM {$table} LIMIT 1"); |
131 | - if($query !== false) |
|
131 | + if ($query !== false) |
|
132 | 132 | { |
133 | 133 | return true; |
134 | 134 | } |
@@ -142,12 +142,12 @@ discard block |
||
142 | 142 | * |
143 | 143 | * @return string |
144 | 144 | */ |
145 | - protected static function checkTableName($tableName, $con=NULL) |
|
145 | + protected static function checkTableName($tableName, $con = NULL) |
|
146 | 146 | { |
147 | 147 | $connection = self::checkConnection($con); |
148 | 148 | |
149 | 149 | $query = $connection->query("SELECT 1 FROM {$tableName} LIMIT 1"); |
150 | - if($query !== false) |
|
150 | + if ($query !== false) |
|
151 | 151 | { |
152 | 152 | return $tableName; |
153 | 153 | } |
@@ -163,13 +163,13 @@ discard block |
||
163 | 163 | * |
164 | 164 | * @return string |
165 | 165 | */ |
166 | - protected static function checkColumn($tableName, $columnName, $con=NULL) |
|
166 | + protected static function checkColumn($tableName, $columnName, $con = NULL) |
|
167 | 167 | { |
168 | 168 | $connection = self::checkConnection($con); |
169 | 169 | |
170 | 170 | $result = $connection->prepare("SELECT {$columnName} FROM {$tableName}"); |
171 | 171 | $result->execute(); |
172 | - if (! $result->columnCount()) |
|
172 | + if ( ! $result->columnCount()) |
|
173 | 173 | { |
174 | 174 | throw new ColumnNotExistExeption(); |
175 | 175 | } |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | { |
217 | 217 | $counter++; |
218 | 218 | $insertQuery .= self::sanitize($key); |
219 | - if($arraySize > $counter) |
|
219 | + if ($arraySize > $counter) |
|
220 | 220 | $insertQuery .= ", "; |
221 | 221 | } |
222 | 222 | |
@@ -240,8 +240,8 @@ discard block |
||
240 | 240 | foreach ($columnNames as $key => $value) |
241 | 241 | { |
242 | 242 | $counter++; |
243 | - $insertQuery .= "'".self::sanitize($value) ."'"; |
|
244 | - if($arraySize > $counter) |
|
243 | + $insertQuery .= "'".self::sanitize($value)."'"; |
|
244 | + if ($arraySize > $counter) |
|
245 | 245 | $insertQuery .= ", "; |
246 | 246 | } |
247 | 247 | return $insertQuery; |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | { |
265 | 265 | $counter++; |
266 | 266 | $columnName = self::checkColumn($tableName, self::sanitize($key)); |
267 | - $updateQuery .= $columnName ." = '".self::sanitize($value)."'"; |
|
267 | + $updateQuery .= $columnName." = '".self::sanitize($value)."'"; |
|
268 | 268 | if ($arraySize > $counter) |
269 | 269 | { |
270 | 270 | $updateQuery .= ", "; |
@@ -299,10 +299,10 @@ discard block |
||
299 | 299 | { |
300 | 300 | $counter++; |
301 | 301 | $columnName = self::checkColumn($tableName, self::sanitize($key)); |
302 | - $where .= $tableName.'.'.$columnName ." = '".self::sanitize($value)."'"; |
|
302 | + $where .= $tableName.'.'.$columnName." = '".self::sanitize($value)."'"; |
|
303 | 303 | if ($arraySize > $counter) |
304 | 304 | { |
305 | - $where .= " " . $condition . " "; |
|
305 | + $where .= " ".$condition." "; |
|
306 | 306 | } |
307 | 307 | } |
308 | 308 | } else { |
@@ -323,14 +323,14 @@ discard block |
||
323 | 323 | try |
324 | 324 | { |
325 | 325 | $arraySize = count($data); |
326 | - if($arraySize > 1 && $condition == NULL) |
|
326 | + if ($arraySize > 1 && $condition == NULL) |
|
327 | 327 | { |
328 | 328 | $query = "Please Supply the condition"; |
329 | 329 | } |
330 | 330 | else |
331 | 331 | { |
332 | 332 | $columnName = self::whereAndClause($tableName, $data, $condition); |
333 | - $query = "SELECT $fields FROM $tableName WHERE $columnName"; |
|
333 | + $query = "SELECT $fields FROM $tableName WHERE $columnName"; |
|
334 | 334 | } |
335 | 335 | } catch (PDOException $e) { |
336 | 336 | $query = $e->getMessage(); |
@@ -362,11 +362,11 @@ discard block |
||
362 | 362 | */ |
363 | 363 | public function updateQuery($tableName) |
364 | 364 | { |
365 | - $data = (array) $this; |
|
365 | + $data = (array)$this; |
|
366 | 366 | $data = array_slice($data, 2); |
367 | 367 | |
368 | 368 | $values = self::buildClause($tableName, $data); |
369 | - $updateQuery = "UPDATE $tableName SET {$values} WHERE id = ". self::sanitize($this->id); |
|
369 | + $updateQuery = "UPDATE $tableName SET {$values} WHERE id = ".self::sanitize($this->id); |
|
370 | 370 | |
371 | 371 | return $updateQuery; |
372 | 372 | } |
@@ -216,8 +216,9 @@ discard block |
||
216 | 216 | { |
217 | 217 | $counter++; |
218 | 218 | $insertQuery .= self::sanitize($key); |
219 | - if($arraySize > $counter) |
|
220 | - $insertQuery .= ", "; |
|
219 | + if($arraySize > $counter) { |
|
220 | + $insertQuery .= ", "; |
|
221 | + } |
|
221 | 222 | } |
222 | 223 | |
223 | 224 | return $insertQuery; |
@@ -241,8 +242,9 @@ discard block |
||
241 | 242 | { |
242 | 243 | $counter++; |
243 | 244 | $insertQuery .= "'".self::sanitize($value) ."'"; |
244 | - if($arraySize > $counter) |
|
245 | - $insertQuery .= ", "; |
|
245 | + if($arraySize > $counter) { |
|
246 | + $insertQuery .= ", "; |
|
247 | + } |
|
246 | 248 | } |
247 | 249 | return $insertQuery; |
248 | 250 | } |
@@ -326,8 +328,7 @@ discard block |
||
326 | 328 | if($arraySize > 1 && $condition == NULL) |
327 | 329 | { |
328 | 330 | $query = "Please Supply the condition"; |
329 | - } |
|
330 | - else |
|
331 | + } else |
|
331 | 332 | { |
332 | 333 | $columnName = self::whereAndClause($tableName, $data, $condition); |
333 | 334 | $query = "SELECT $fields FROM $tableName WHERE $columnName"; |
@@ -42,12 +42,10 @@ |
||
42 | 42 | if ($this->driver === 'pgsql' || $this->driver === 'postgres') |
43 | 43 | { |
44 | 44 | parent::__construct($this->pgsqlConnectionString()); |
45 | - } |
|
46 | - elseif ($this->driver === 'mysql') |
|
45 | + } elseif ($this->driver === 'mysql') |
|
47 | 46 | { |
48 | 47 | parent::__construct($this->mysqlConnectionString(), $this->user, $this->password); |
49 | - } |
|
50 | - elseif($this->driver === 'sqlite') |
|
48 | + } elseif($this->driver === 'sqlite') |
|
51 | 49 | { |
52 | 50 | parent::__construct($this->sqlitConnectionString()); |
53 | 51 | } |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | { |
48 | 48 | parent::__construct($this->mysqlConnectionString(), $this->user, $this->password); |
49 | 49 | } |
50 | - elseif($this->driver === 'sqlite') |
|
50 | + elseif ($this->driver === 'sqlite') |
|
51 | 51 | { |
52 | 52 | parent::__construct($this->sqlitConnectionString()); |
53 | 53 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | */ |
64 | 64 | protected function pgsqlConnectionString() |
65 | 65 | { |
66 | - return $this->driver . ':host=' . $this->host . ';port=' . $this->port . ';dbname=' . $this->dbname . ';user=' . $this->user . ';password=' . $this->password; |
|
66 | + return $this->driver.':host='.$this->host.';port='.$this->port.';dbname='.$this->dbname.';user='.$this->user.';password='.$this->password; |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | */ |
74 | 74 | protected function mysqlConnectionString() |
75 | 75 | { |
76 | - return $this->driver . ':host=' . $this->host . ';dbname=' . $this->dbname . ';charset=utf8mb4'; |
|
76 | + return $this->driver.':host='.$this->host.';dbname='.$this->dbname.';charset=utf8mb4'; |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | */ |
84 | 84 | protected function sqlitConnectionString() |
85 | 85 | { |
86 | - return $this->driver . ':' . $this->sqlitePath; |
|
86 | + return $this->driver.':'.$this->sqlitePath; |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | */ |
92 | 92 | protected function loadEnv() |
93 | 93 | { |
94 | - if( ! getenv("APP_ENV")) |
|
94 | + if ( ! getenv("APP_ENV")) |
|
95 | 95 | { |
96 | 96 | $dotenv = new Dotenv($_SERVER['DOCUMENT_ROOT']); |
97 | 97 | $dotenv->load(); |
@@ -39,13 +39,13 @@ discard block |
||
39 | 39 | trait Inflector |
40 | 40 | { |
41 | 41 | /** |
42 | - * Pluralizes English nouns. |
|
43 | - * |
|
44 | - * @access public |
|
45 | - * @static |
|
46 | - * @param string $word English noun to pluralize |
|
47 | - * @return string Plural noun |
|
48 | - */ |
|
42 | + * Pluralizes English nouns. |
|
43 | + * |
|
44 | + * @access public |
|
45 | + * @static |
|
46 | + * @param string $word English noun to pluralize |
|
47 | + * @return string Plural noun |
|
48 | + */ |
|
49 | 49 | public static function pluralize($word) |
50 | 50 | { |
51 | 51 | $plural = array( |
@@ -102,13 +102,13 @@ discard block |
||
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
105 | - * Singularizes English nouns. |
|
106 | - * |
|
107 | - * @access public |
|
108 | - * @static |
|
109 | - * @param string $word English noun to singularize |
|
110 | - * @return string Singular noun. |
|
111 | - */ |
|
105 | + * Singularizes English nouns. |
|
106 | + * |
|
107 | + * @access public |
|
108 | + * @static |
|
109 | + * @param string $word English noun to singularize |
|
110 | + * @return string Singular noun. |
|
111 | + */ |
|
112 | 112 | public function singularize($word) |
113 | 113 | { |
114 | 114 | $singular = array ( |
@@ -81,15 +81,15 @@ discard block |
||
81 | 81 | |
82 | 82 | $lowercased_word = strtolower($word); |
83 | 83 | |
84 | - foreach ($uncountable as $_uncountable){ |
|
85 | - if(substr($lowercased_word,(-1*strlen($_uncountable))) == $_uncountable){ |
|
84 | + foreach ($uncountable as $_uncountable) { |
|
85 | + if (substr($lowercased_word, (-1*strlen($_uncountable))) == $_uncountable) { |
|
86 | 86 | return $word; |
87 | 87 | } |
88 | 88 | } |
89 | 89 | |
90 | - foreach ($irregular as $_plural=> $_singular){ |
|
90 | + foreach ($irregular as $_plural=> $_singular) { |
|
91 | 91 | if (preg_match('/('.$_plural.')$/i', $word, $arr)) { |
92 | - return preg_replace('/('.$_plural.')$/i', substr($arr[0],0,1).substr($_singular,1), $word); |
|
92 | + return preg_replace('/('.$_plural.')$/i', substr($arr[0], 0, 1).substr($_singular, 1), $word); |
|
93 | 93 | } |
94 | 94 | } |
95 | 95 | |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | */ |
112 | 112 | public function singularize($word) |
113 | 113 | { |
114 | - $singular = array ( |
|
114 | + $singular = array( |
|
115 | 115 | '/(quiz)zes$/i' => "$1", |
116 | 116 | '/(matr)ices$/i' => "$1ix", |
117 | 117 | '/(vert|ind)ices$/i' => "$1ex", |
@@ -152,15 +152,15 @@ discard block |
||
152 | 152 | 'move' => 'moves'); |
153 | 153 | |
154 | 154 | $lowercased_word = strtolower($word); |
155 | - foreach ($uncountable as $_uncountable){ |
|
156 | - if(substr($lowercased_word,(-1*strlen($_uncountable))) == $_uncountable){ |
|
155 | + foreach ($uncountable as $_uncountable) { |
|
156 | + if (substr($lowercased_word, (-1*strlen($_uncountable))) == $_uncountable) { |
|
157 | 157 | return $word; |
158 | 158 | } |
159 | 159 | } |
160 | 160 | |
161 | - foreach ($irregular as $_plural=> $_singular){ |
|
161 | + foreach ($irregular as $_plural=> $_singular) { |
|
162 | 162 | if (preg_match('/('.$_singular.')$/i', $word, $arr)) { |
163 | - return preg_replace('/('.$_singular.')$/i', substr($arr[0],0,1).substr($_plural,1), $word); |
|
163 | + return preg_replace('/('.$_singular.')$/i', substr($arr[0], 0, 1).substr($_plural, 1), $word); |
|
164 | 164 | } |
165 | 165 | } |
166 | 166 |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | { |
30 | 30 | if(is_null($length)){ |
31 | 31 | $this->fieldDescription[] = $type ." ".$fieldName; |
32 | - }else |
|
32 | + } else |
|
33 | 33 | { |
34 | 34 | $this->fieldDescription[] = $type ." ".$fieldName." ".$length; |
35 | 35 | } |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | if(sizeof($e) == 2) |
53 | 53 | { |
54 | 54 | $query .= $this->$e[0]($e[1], 20) .", ".PHP_EOL; |
55 | - }else |
|
55 | + } else |
|
56 | 56 | { |
57 | 57 | $query .= $this->$e[0]($e[1], $e[2]) .", ".PHP_EOL; |
58 | 58 | } |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | { |
95 | 95 | return true; |
96 | 96 | } |
97 | - }catch(PDOException $e){ |
|
97 | + } catch(PDOException $e){ |
|
98 | 98 | return $e->getMessage(); |
99 | 99 | } |
100 | 100 | } |
@@ -25,13 +25,13 @@ discard block |
||
25 | 25 | * |
26 | 26 | * @return array |
27 | 27 | */ |
28 | - public function field($type, $fieldName, $length=NULL) |
|
28 | + public function field($type, $fieldName, $length = NULL) |
|
29 | 29 | { |
30 | - if($length === null){ |
|
31 | - $this->fieldDescription[] = $type ." ".$fieldName; |
|
32 | - }else |
|
30 | + if ($length === null) { |
|
31 | + $this->fieldDescription[] = $type." ".$fieldName; |
|
32 | + } else |
|
33 | 33 | { |
34 | - $this->fieldDescription[] = $type ." ".$fieldName." ".$length; |
|
34 | + $this->fieldDescription[] = $type." ".$fieldName." ".$length; |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | } |
@@ -51,12 +51,12 @@ discard block |
||
51 | 51 | $fields = explode(" ", $fieldName); |
52 | 52 | |
53 | 53 | $constrain = $fields[0]; |
54 | - if(count($fields) == 2) |
|
54 | + if (count($fields) == 2) |
|
55 | 55 | { |
56 | - $query .= $this->$constrain($fields[1], 20) .", ".PHP_EOL; |
|
57 | - }else |
|
56 | + $query .= $this->$constrain($fields[1], 20).", ".PHP_EOL; |
|
57 | + } else |
|
58 | 58 | { |
59 | - $query .= $this->$constrain($fields[1], $fields[2]) .", ".PHP_EOL; |
|
59 | + $query .= $this->$constrain($fields[1], $fields[2]).", ".PHP_EOL; |
|
60 | 60 | } |
61 | 61 | }; |
62 | 62 | array_walk($this->fieldDescription, $callback); |
@@ -90,11 +90,11 @@ discard block |
||
90 | 90 | { |
91 | 91 | $sqlQuery = self::sanitizeQuery($tablename); |
92 | 92 | $query = $connection->prepare($sqlQuery); |
93 | - if($query->execute()) |
|
93 | + if ($query->execute()) |
|
94 | 94 | { |
95 | 95 | return true; |
96 | 96 | } |
97 | - }catch(PDOException $e){ |
|
97 | + } catch (PDOException $e) { |
|
98 | 98 | return $e->getMessage(); |
99 | 99 | } |
100 | 100 | } |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | */ |
117 | 117 | public function strings($value, $length) |
118 | 118 | { |
119 | - return $value ." varchar (".$length.") NOT NULL"; |
|
119 | + return $value." varchar (".$length.") NOT NULL"; |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
@@ -202,6 +202,6 @@ discard block |
||
202 | 202 | $apend = 'timestamp'; |
203 | 203 | break; |
204 | 204 | } |
205 | - return $value . " " . $apend . " NOT NULL"; |
|
205 | + return $value." ".$apend." NOT NULL"; |
|
206 | 206 | } |
207 | 207 | } |
208 | 208 | \ No newline at end of file |
@@ -28,10 +28,10 @@ |
||
28 | 28 | public function field($type, $fieldName, $length=NULL) |
29 | 29 | { |
30 | 30 | if($length === null){ |
31 | - $this->fieldDescription[] = $type ." ".$fieldName; |
|
31 | + $this->fieldDescription[] = $type ." ".$fieldName; |
|
32 | 32 | }else |
33 | 33 | { |
34 | - $this->fieldDescription[] = $type ." ".$fieldName." ".$length; |
|
34 | + $this->fieldDescription[] = $type ." ".$fieldName." ".$length; |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | } |
@@ -25,6 +25,6 @@ |
||
25 | 25 | */ |
26 | 26 | public function errorMessage() |
27 | 27 | { |
28 | - return "Error: " . $this->getMessage(); |
|
28 | + return "Error: ".$this->getMessage(); |
|
29 | 29 | } |
30 | 30 | } |
31 | 31 | \ No newline at end of file |
@@ -25,6 +25,6 @@ |
||
25 | 25 | */ |
26 | 26 | public function errorMessage() |
27 | 27 | { |
28 | - return "Error: " . $this->getMessage(); |
|
28 | + return "Error: ".$this->getMessage(); |
|
29 | 29 | } |
30 | 30 | } |
31 | 31 | \ No newline at end of file |
@@ -9,17 +9,12 @@ |
||
9 | 9 | |
10 | 10 | namespace Ibonly\PotatoORM; |
11 | 11 | |
12 | -use PDO; |
|
13 | -use Exception; |
|
14 | -use PDOException; |
|
15 | 12 | use Ibonly\PotatoORM\GetData; |
16 | 13 | use Ibonly\PotatoORM\DatabaseQuery; |
17 | 14 | use Ibonly\PotatoORM\ModelInterface; |
18 | 15 | use Ibonly\PotatoORM\UserNotFoundException; |
19 | 16 | use Ibonly\PotatoORM\EmptyDatabaseException; |
20 | 17 | use Ibonly\PotatoORM\SaveUserExistException; |
21 | -use Ibonly\PotatoORM\ColumnNotExistExeption; |
|
22 | -use Ibonly\PotatoORM\InvalidConnectionException; |
|
23 | 18 | |
24 | 19 | class Model extends DatabaseQuery implements ModelInterface |
25 | 20 | { |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * getALL() |
26 | 26 | * Get all record from the database |
27 | 27 | * |
28 | - * @return object |
|
28 | + * @return GetData |
|
29 | 29 | */ |
30 | 30 | public function getAll($dbConnection = NULL) |
31 | 31 | { |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * where($data, $condition) |
45 | 45 | * Get data from database where $data = $condition |
46 | 46 | * |
47 | - * @return object |
|
47 | + * @return GetData |
|
48 | 48 | */ |
49 | 49 | public function where($data, $condition = NULL, $dbConnection = NULL) |
50 | 50 | { |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * find($value) |
65 | 65 | * Find data from database where id = $value |
66 | 66 | * |
67 | - * @return array |
|
67 | + * @return Model |
|
68 | 68 | */ |
69 | 69 | public static function find($value, $dbConnection = NULL) |
70 | 70 | { |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | |
95 | 95 | $query = $this->insertQuery(self::getTableName($connection)); |
96 | 96 | $statement = $connection->prepare($query); |
97 | - if($statement->execute()) { |
|
97 | + if ($statement->execute()) { |
|
98 | 98 | return true; |
99 | 99 | } |
100 | 100 | throw new DataAlreadyExistException(); |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | { |
130 | 130 | $connection = DatabaseQuery::checkConnection($dbConnection); |
131 | 131 | |
132 | - $query = $connection->prepare('DELETE FROM ' . self::getTableName($connection) . ' WHERE id = '.$value); |
|
132 | + $query = $connection->prepare('DELETE FROM '.self::getTableName($connection).' WHERE id = '.$value); |
|
133 | 133 | $query->execute(); |
134 | 134 | $check = $query->rowCount(); |
135 | 135 | if ($check) { |
@@ -25,6 +25,6 @@ |
||
25 | 25 | */ |
26 | 26 | public function errorMessage() |
27 | 27 | { |
28 | - return "Error: " . $this->getMessage(); |
|
28 | + return "Error: ".$this->getMessage(); |
|
29 | 29 | } |
30 | 30 | } |
31 | 31 | \ No newline at end of file |
@@ -25,6 +25,6 @@ |
||
25 | 25 | */ |
26 | 26 | public function errorMessage() |
27 | 27 | { |
28 | - return "Error: " . $this->getMessage(); |
|
28 | + return "Error: ".$this->getMessage(); |
|
29 | 29 | } |
30 | 30 | } |
31 | 31 | \ No newline at end of file |