@@ -11,7 +11,7 @@ |
||
11 | 11 | |
12 | 12 | interface RelationshipsInterface |
13 | 13 | { |
14 | - public function joinClause(); |
|
14 | + public function joinClause(); |
|
15 | 15 | |
16 | 16 | public function whereClause($data, $condition); |
17 | 17 | } |
18 | 18 | \ No newline at end of file |
@@ -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 | } |
@@ -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) { |
@@ -94,12 +94,12 @@ discard block |
||
94 | 94 | $Extension = strtolower($FileParts['extension']); |
95 | 95 | $ValidExtensions = $this->ValidExtensions; |
96 | 96 | |
97 | - if (!$FileName) { |
|
97 | + if ( ! $FileName) { |
|
98 | 98 | $this->SetMessage("ERROR: File name is empty."); |
99 | 99 | return false; |
100 | 100 | } |
101 | 101 | |
102 | - if (!$ValidExtensions) { |
|
102 | + if ( ! $ValidExtensions) { |
|
103 | 103 | $this->SetMessage("WARNING: All extensions are valid."); |
104 | 104 | return true; |
105 | 105 | } |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | $TempFileName = $this->GetTempName(); |
125 | 125 | $TempFileSize = filesize($TempFileName); |
126 | 126 | |
127 | - if($MaximumFileSize == "") { |
|
127 | + if ($MaximumFileSize == "") { |
|
128 | 128 | $this->SetMessage("WARNING: There is no size restriction."); |
129 | 129 | return true; |
130 | 130 | } |
@@ -146,11 +146,11 @@ discard block |
||
146 | 146 | public function ValidateExistance($uploadDirectory) |
147 | 147 | { |
148 | 148 | $FileName = $this->GetFileName(); |
149 | - $File = $uploadDirectory . $FileName; |
|
149 | + $File = $uploadDirectory.$FileName; |
|
150 | 150 | |
151 | 151 | if (file_exists($File)) { |
152 | 152 | $this->SetMessage("Message: The file '$FileName' already exist."); |
153 | - $UniqueName = rand() . $FileName; |
|
153 | + $UniqueName = rand().$FileName; |
|
154 | 154 | $this->SetFileName($UniqueName); |
155 | 155 | $this->ValidateExistance($uploadDirectory); |
156 | 156 | } else { |
@@ -166,24 +166,24 @@ discard block |
||
166 | 166 | */ |
167 | 167 | public function ValidateDirectory($uploadDirectory) |
168 | 168 | { |
169 | - if (! $uploadDirectory) { |
|
169 | + if ( ! $uploadDirectory) { |
|
170 | 170 | $this->SetMessage("ERROR: The directory variable is empty."); |
171 | 171 | return false; |
172 | 172 | } |
173 | 173 | |
174 | - if (!is_dir($uploadDirectory)) { |
|
174 | + if ( ! is_dir($uploadDirectory)) { |
|
175 | 175 | $this->SetMessage("ERROR: The directory '$uploadDirectory' does not exist."); |
176 | 176 | return false; |
177 | 177 | } |
178 | 178 | |
179 | - if (!is_writable($uploadDirectory)) { |
|
179 | + if ( ! is_writable($uploadDirectory)) { |
|
180 | 180 | $this->SetMessage("ERROR: The directory '$uploadDirectory' does not writable."); |
181 | 181 | return false; |
182 | 182 | } |
183 | 183 | |
184 | 184 | if (substr($uploadDirectory, -1) != "/") { |
185 | 185 | $this->SetMessage("ERROR: The traling slash does not exist."); |
186 | - $NewDirectory = $uploadDirectory . "/"; |
|
186 | + $NewDirectory = $uploadDirectory."/"; |
|
187 | 187 | $this->SetUploadDirectory($NewDirectory); |
188 | 188 | $this->ValidateDirectory($uploadDirectory); |
189 | 189 | } else { |
@@ -202,9 +202,9 @@ discard block |
||
202 | 202 | $MaximumHeight = $this->MaximumHeight; |
203 | 203 | $TempFileName = $this->GetTempName(); |
204 | 204 | |
205 | - if($Size = @getimagesize($TempFileName)) { |
|
206 | - $Width = $Size[0]; //$Width is the width in pixels of the image uploaded to the server. |
|
207 | - $Height = $Size[1]; //$Height is the height in pixels of the image uploaded to the server. |
|
205 | + if ($Size = @getimagesize($TempFileName)) { |
|
206 | + $Width = $Size[0]; //$Width is the width in pixels of the image uploaded to the server. |
|
207 | + $Height = $Size[1]; //$Height is the height in pixels of the image uploaded to the server. |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | if ($Width > $MaximumWidth) { |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | |
324 | 324 | public function GetMessage() |
325 | 325 | { |
326 | - if (!isset($this->Message)) { |
|
326 | + if ( ! isset($this->Message)) { |
|
327 | 327 | $this->SetMessage("No Message"); |
328 | 328 | } |
329 | 329 |
@@ -25,36 +25,36 @@ |
||
25 | 25 | $i = 0; |
26 | 26 | |
27 | 27 | if ($data[0]->REFERENCED_TABLE_NAME !== null) { |
28 | - $arraySize = count($data); |
|
29 | - |
|
30 | - foreach($data as $key => $value) { |
|
31 | - $output .= ' JOIN '.$value->REFERENCED_TABLE_NAME; |
|
32 | - } |
|
33 | - foreach($data as $key => $value) { |
|
34 | - $i++; |
|
35 | - $whereAnd = $i > 1 ? 'AND' : 'WHERE'; |
|
36 | - $output .= ' '.$whereAnd.' '.self::getTableName($connection).'.'.$value->COLUMN_NAME.'='.$value->REFERENCED_TABLE_NAME.'.'.$value->REFERENCED_COLUMN_NAME.' '; |
|
37 | - } |
|
38 | - } else { |
|
39 | - $output = false; |
|
40 | - } |
|
28 | + $arraySize = count($data); |
|
29 | + |
|
30 | + foreach($data as $key => $value) { |
|
31 | + $output .= ' JOIN '.$value->REFERENCED_TABLE_NAME; |
|
32 | + } |
|
33 | + foreach($data as $key => $value) { |
|
34 | + $i++; |
|
35 | + $whereAnd = $i > 1 ? 'AND' : 'WHERE'; |
|
36 | + $output .= ' '.$whereAnd.' '.self::getTableName($connection).'.'.$value->COLUMN_NAME.'='.$value->REFERENCED_TABLE_NAME.'.'.$value->REFERENCED_COLUMN_NAME.' '; |
|
37 | + } |
|
38 | + } else { |
|
39 | + $output = false; |
|
40 | + } |
|
41 | 41 | return $output; |
42 | 42 | } |
43 | 43 | |
44 | 44 | public function whereClause($data = null, $condition = null, $con = null) |
45 | 45 | { |
46 | - $joinClause = self::joinClause(); |
|
46 | + $joinClause = self::joinClause(); |
|
47 | 47 | $connection = self::checkConnection($con); |
48 | 48 | $tableName = self::getTableName($connection); |
49 | 49 | $columnName = self::whereAndClause($tableName, $data, $condition); |
50 | 50 | |
51 | - $query = 'SELECT * FROM '.$tableName; |
|
51 | + $query = 'SELECT * FROM '.$tableName; |
|
52 | 52 | |
53 | - if (! $joinClause) { |
|
54 | - $query .= ' WHERE '.$columnName; |
|
55 | - } else { |
|
56 | - $query .= ($data === null) ? $joinClause : $joinClause .' AND '.$columnName; |
|
57 | - } |
|
58 | - return $query; |
|
53 | + if (! $joinClause) { |
|
54 | + $query .= ' WHERE '.$columnName; |
|
55 | + } else { |
|
56 | + $query .= ($data === null) ? $joinClause : $joinClause .' AND '.$columnName; |
|
57 | + } |
|
58 | + return $query; |
|
59 | 59 | } |
60 | 60 | } |
61 | 61 | \ No newline at end of file |
@@ -25,12 +25,12 @@ discard block |
||
25 | 25 | $i = 0; |
26 | 26 | |
27 | 27 | if ($data[0]->REFERENCED_TABLE_NAME !== null) { |
28 | - $arraySize = count($data); |
|
28 | + $arraySize = count($data); |
|
29 | 29 | |
30 | - foreach($data as $key => $value) { |
|
30 | + foreach ($data as $key => $value) { |
|
31 | 31 | $output .= ' JOIN '.$value->REFERENCED_TABLE_NAME; |
32 | 32 | } |
33 | - foreach($data as $key => $value) { |
|
33 | + foreach ($data as $key => $value) { |
|
34 | 34 | $i++; |
35 | 35 | $whereAnd = $i > 1 ? 'AND' : 'WHERE'; |
36 | 36 | $output .= ' '.$whereAnd.' '.self::getTableName($connection).'.'.$value->COLUMN_NAME.'='.$value->REFERENCED_TABLE_NAME.'.'.$value->REFERENCED_COLUMN_NAME.' '; |
@@ -50,10 +50,10 @@ discard block |
||
50 | 50 | |
51 | 51 | $query = 'SELECT * FROM '.$tableName; |
52 | 52 | |
53 | - if (! $joinClause) { |
|
53 | + if ( ! $joinClause) { |
|
54 | 54 | $query .= ' WHERE '.$columnName; |
55 | 55 | } else { |
56 | - $query .= ($data === null) ? $joinClause : $joinClause .' AND '.$columnName; |
|
56 | + $query .= ($data === null) ? $joinClause : $joinClause.' AND '.$columnName; |
|
57 | 57 | } |
58 | 58 | return $query; |
59 | 59 | } |