@@ -73,11 +73,11 @@ discard block |
||
| 73 | 73 | { |
| 74 | 74 | $k++; |
| 75 | 75 | |
| 76 | - if (is_null($value)) |
|
| 77 | - $parsed_where[] = "$key IS NULL"; |
|
| 78 | - elseif ($value instanceof SQLFunction) |
|
| 79 | - $parsed_where[] = "$key = " . $value->getStatement(); |
|
| 80 | - elseif (is_array($value)) |
|
| 76 | + if (is_null($value)) { |
|
| 77 | + $parsed_where[] = "$key IS NULL"; |
|
| 78 | + } elseif ($value instanceof SQLFunction) { |
|
| 79 | + $parsed_where[] = "$key = " . $value->getStatement(); |
|
| 80 | + } elseif (is_array($value)) |
|
| 81 | 81 | { |
| 82 | 82 | $parsed_in = []; |
| 83 | 83 | |
@@ -100,8 +100,7 @@ discard block |
||
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | $parsed_where[] = "$key IN (" . implode(", ", $parsed_in) . ")"; |
| 103 | - } |
|
| 104 | - else |
|
| 103 | + } else |
|
| 105 | 104 | { |
| 106 | 105 | switch ($driver) |
| 107 | 106 | { |
@@ -119,18 +118,19 @@ discard block |
||
| 119 | 118 | } |
| 120 | 119 | |
| 121 | 120 | $where = "WHERE \r\n\t" . implode(" AND\r\n\t", $parsed_where); |
| 121 | + } else { |
|
| 122 | + $where = ""; |
|
| 122 | 123 | } |
| 123 | - else |
|
| 124 | - $where = ""; |
|
| 125 | 124 | |
| 126 | 125 | $table = $this->entity->getTableName(); |
| 127 | 126 | |
| 128 | 127 | $sql = "SELECT * \r\nFROM {$table}\r\n$where"; |
| 129 | 128 | |
| 130 | - if (count($bind_values)) |
|
| 131 | - $this->getDriver()->getDb()->execute($sql, $bind_values); |
|
| 132 | - else |
|
| 133 | - $this->getDriver()->getDb()->execute($sql); |
|
| 129 | + if (count($bind_values)) { |
|
| 130 | + $this->getDriver()->getDb()->execute($sql, $bind_values); |
|
| 131 | + } else { |
|
| 132 | + $this->getDriver()->getDb()->execute($sql); |
|
| 133 | + } |
|
| 134 | 134 | |
| 135 | 135 | return $this->getDriver()->getDb()->getArrayResult(); |
| 136 | 136 | } |
@@ -147,8 +147,9 @@ discard block |
||
| 147 | 147 | */ |
| 148 | 148 | public function insert(Array $data) |
| 149 | 149 | { |
| 150 | - if (!count($data)) |
|
| 151 | - throw new \LogicException("Missing values for INSERT statement!"); |
|
| 150 | + if (!count($data)) { |
|
| 151 | + throw new \LogicException("Missing values for INSERT statement!"); |
|
| 152 | + } |
|
| 152 | 153 | |
| 153 | 154 | $bind_values = []; |
| 154 | 155 | |
@@ -171,11 +172,11 @@ discard block |
||
| 171 | 172 | continue; |
| 172 | 173 | } |
| 173 | 174 | |
| 174 | - if (is_null($value)) |
|
| 175 | - $value = "NULL"; |
|
| 176 | - elseif ($value instanceof SQLFunction) |
|
| 177 | - $value = $value->getStatement(); |
|
| 178 | - else { |
|
| 175 | + if (is_null($value)) { |
|
| 176 | + $value = "NULL"; |
|
| 177 | + } elseif ($value instanceof SQLFunction) { |
|
| 178 | + $value = $value->getStatement(); |
|
| 179 | + } else { |
|
| 179 | 180 | |
| 180 | 181 | switch ($driver) |
| 181 | 182 | { |
@@ -225,11 +226,13 @@ discard block |
||
| 225 | 226 | { |
| 226 | 227 | $parsed_set = []; |
| 227 | 228 | |
| 228 | - if (!count($set)) |
|
| 229 | - throw new \LogicException("You cannot update rows without SET clause"); |
|
| 229 | + if (!count($set)) { |
|
| 230 | + throw new \LogicException("You cannot update rows without SET clause"); |
|
| 231 | + } |
|
| 230 | 232 | |
| 231 | - if (!count($where)) |
|
| 232 | - throw new SecurityException("You cannot update rows without WHERE clause!"); |
|
| 233 | + if (!count($where)) { |
|
| 234 | + throw new SecurityException("You cannot update rows without WHERE clause!"); |
|
| 235 | + } |
|
| 233 | 236 | |
| 234 | 237 | $bind_values = []; |
| 235 | 238 | |
@@ -241,11 +244,11 @@ discard block |
||
| 241 | 244 | { |
| 242 | 245 | $k++; |
| 243 | 246 | |
| 244 | - if (is_null($value)) |
|
| 245 | - $parsed_set[] = "$key = NULL"; |
|
| 246 | - elseif ($value instanceof SQLFunction) |
|
| 247 | - $parsed_set[] = "$key = " . $value->getStatement(); |
|
| 248 | - elseif (is_array($value)) |
|
| 247 | + if (is_null($value)) { |
|
| 248 | + $parsed_set[] = "$key = NULL"; |
|
| 249 | + } elseif ($value instanceof SQLFunction) { |
|
| 250 | + $parsed_set[] = "$key = " . $value->getStatement(); |
|
| 251 | + } elseif (is_array($value)) |
|
| 249 | 252 | { |
| 250 | 253 | $parsed_in = []; |
| 251 | 254 | |
@@ -256,8 +259,9 @@ discard block |
||
| 256 | 259 | case 'Oci8': |
| 257 | 260 | |
| 258 | 261 | # [POSSIBLE BUG] - To Future revision (What about non-string values ?) |
| 259 | - if (is_string($in_value)) |
|
| 260 | - $parsed_in[] = ":$k"; |
|
| 262 | + if (is_string($in_value)) { |
|
| 263 | + $parsed_in[] = ":$k"; |
|
| 264 | + } |
|
| 261 | 265 | |
| 262 | 266 | $bind_values[":$k"] = $in_value; |
| 263 | 267 | break; |
@@ -272,8 +276,7 @@ discard block |
||
| 272 | 276 | } |
| 273 | 277 | |
| 274 | 278 | $parsed_set[] = "$key IN (" . implode(", ", $parsed_in) . ")"; |
| 275 | - } |
|
| 276 | - else |
|
| 279 | + } else |
|
| 277 | 280 | { |
| 278 | 281 | switch ($driver) |
| 279 | 282 | { |
@@ -298,11 +301,11 @@ discard block |
||
| 298 | 301 | { |
| 299 | 302 | $k++; |
| 300 | 303 | |
| 301 | - if (is_null($value)) |
|
| 302 | - $parsed_where[] = "$key IS NULL"; |
|
| 303 | - elseif ($value instanceof SQLFunction) |
|
| 304 | - $parsed_where[] = "$key = " . $value->getStatement(); |
|
| 305 | - elseif (is_array($value)) |
|
| 304 | + if (is_null($value)) { |
|
| 305 | + $parsed_where[] = "$key IS NULL"; |
|
| 306 | + } elseif ($value instanceof SQLFunction) { |
|
| 307 | + $parsed_where[] = "$key = " . $value->getStatement(); |
|
| 308 | + } elseif (is_array($value)) |
|
| 306 | 309 | { |
| 307 | 310 | $parsed_in = []; |
| 308 | 311 | |
@@ -325,8 +328,7 @@ discard block |
||
| 325 | 328 | } |
| 326 | 329 | |
| 327 | 330 | $parsed_where[] = "$key IN (" . implode(", ", $parsed_in) . ")"; |
| 328 | - } |
|
| 329 | - else |
|
| 331 | + } else |
|
| 330 | 332 | { |
| 331 | 333 | switch ($driver) |
| 332 | 334 | { |
@@ -378,11 +380,11 @@ discard block |
||
| 378 | 380 | { |
| 379 | 381 | $k++; |
| 380 | 382 | |
| 381 | - if (is_null($value)) |
|
| 382 | - $parsed_where[] = "$key IS NULL"; |
|
| 383 | - elseif ($value instanceof SQLFunction) |
|
| 384 | - $parsed_where[] = "$key = " . $value->getStatement(); |
|
| 385 | - elseif (is_array($value)) |
|
| 383 | + if (is_null($value)) { |
|
| 384 | + $parsed_where[] = "$key IS NULL"; |
|
| 385 | + } elseif ($value instanceof SQLFunction) { |
|
| 386 | + $parsed_where[] = "$key = " . $value->getStatement(); |
|
| 387 | + } elseif (is_array($value)) |
|
| 386 | 388 | { |
| 387 | 389 | $parsed_in = []; |
| 388 | 390 | |
@@ -405,8 +407,7 @@ discard block |
||
| 405 | 407 | } |
| 406 | 408 | |
| 407 | 409 | $parsed_where[] = "$key IN (" . implode(", ", $parsed_in) . ")"; |
| 408 | - } |
|
| 409 | - else |
|
| 410 | + } else |
|
| 410 | 411 | { |
| 411 | 412 | switch ($driver) |
| 412 | 413 | { |
@@ -424,9 +425,9 @@ discard block |
||
| 424 | 425 | } |
| 425 | 426 | |
| 426 | 427 | $where = "\r\nWHERE \r\n\t" . implode(" AND\r\n\t", $parsed_where); |
| 428 | + } else { |
|
| 429 | + throw new SecurityException("You cannot delete rows without WHERE clause!. Use TRUNCATE statement instead."); |
|
| 427 | 430 | } |
| 428 | - else |
|
| 429 | - throw new SecurityException("You cannot delete rows without WHERE clause!. Use TRUNCATE statement instead."); |
|
| 430 | 431 | |
| 431 | 432 | $table = $this->entity->getTableName(); |
| 432 | 433 | |
@@ -209,8 +209,9 @@ discard block |
||
| 209 | 209 | */ |
| 210 | 210 | public function getArrayResult() |
| 211 | 211 | { |
| 212 | - if (!empty($this->arrayResult)) |
|
| 213 | - return $this->arrayResult; |
|
| 212 | + if (!empty($this->arrayResult)) { |
|
| 213 | + return $this->arrayResult; |
|
| 214 | + } |
|
| 214 | 215 | |
| 215 | 216 | return $this->toArray(); |
| 216 | 217 | } |
@@ -298,8 +299,9 @@ discard block |
||
| 298 | 299 | { |
| 299 | 300 | foreach ($options as $option => $value) |
| 300 | 301 | { |
| 301 | - if (property_exists(__CLASS__, strtolower($option)) && method_exists($this, 'set'.$option)) |
|
| 302 | - $this->{'set'.$option}($value); |
|
| 302 | + if (property_exists(__CLASS__, strtolower($option)) && method_exists($this, 'set'.$option)) { |
|
| 303 | + $this->{'set'.$option}($value); |
|
| 304 | + } |
|
| 303 | 305 | } |
| 304 | 306 | } |
| 305 | 307 | |
@@ -343,8 +345,9 @@ discard block |
||
| 343 | 345 | */ |
| 344 | 346 | public function reconnect() |
| 345 | 347 | { |
| 346 | - if (!$this->isConnected()) |
|
| 347 | - throw new \LogicException("Connection was not established"); |
|
| 348 | + if (!$this->isConnected()) { |
|
| 349 | + throw new \LogicException("Connection was not established"); |
|
| 350 | + } |
|
| 348 | 351 | |
| 349 | 352 | $this->disconnect(); |
| 350 | 353 | return $this->connect(); |
@@ -373,8 +376,9 @@ discard block |
||
| 373 | 376 | */ |
| 374 | 377 | public function disconnect() |
| 375 | 378 | { |
| 376 | - if (!$this->isConnected()) |
|
| 377 | - throw new \LogicException("Connection was not established"); |
|
| 379 | + if (!$this->isConnected()) { |
|
| 380 | + throw new \LogicException("Connection was not established"); |
|
| 381 | + } |
|
| 378 | 382 | } |
| 379 | 383 | |
| 380 | 384 | /** |
@@ -386,11 +390,13 @@ discard block |
||
| 386 | 390 | */ |
| 387 | 391 | public function beginTransaction() |
| 388 | 392 | { |
| 389 | - if (!$this->isConnected()) |
|
| 390 | - $this->connect(); |
|
| 393 | + if (!$this->isConnected()) { |
|
| 394 | + $this->connect(); |
|
| 395 | + } |
|
| 391 | 396 | |
| 392 | - if ($this->transac_mode) |
|
| 393 | - throw new \LogicException($this->standardErrors[Errno::DB_TRANSACTION_STARTED]); |
|
| 397 | + if ($this->transac_mode) { |
|
| 398 | + throw new \LogicException($this->standardErrors[Errno::DB_TRANSACTION_STARTED]); |
|
| 399 | + } |
|
| 394 | 400 | |
| 395 | 401 | $this->transac_mode = true; |
| 396 | 402 | } |
@@ -404,16 +410,19 @@ discard block |
||
| 404 | 410 | */ |
| 405 | 411 | public function endTransaction() |
| 406 | 412 | { |
| 407 | - if (!$this->transac_mode) |
|
| 408 | - throw new \LogicException($this->standardErrors[Errno::DB_TRANSACTION_NOT_STARTED]); |
|
| 413 | + if (!$this->transac_mode) { |
|
| 414 | + throw new \LogicException($this->standardErrors[Errno::DB_TRANSACTION_NOT_STARTED]); |
|
| 415 | + } |
|
| 409 | 416 | |
| 410 | - if (is_null($this->transac_result)) |
|
| 411 | - throw new \LogicException($this->standardErrors[Errno::DB_TRANSACTION_EMPTY]); |
|
| 417 | + if (is_null($this->transac_result)) { |
|
| 418 | + throw new \LogicException($this->standardErrors[Errno::DB_TRANSACTION_EMPTY]); |
|
| 419 | + } |
|
| 412 | 420 | |
| 413 | - if ($this->transac_result) |
|
| 414 | - $this->commit(); |
|
| 415 | - else |
|
| 416 | - $this->rollback(); |
|
| 421 | + if ($this->transac_result) { |
|
| 422 | + $this->commit(); |
|
| 423 | + } else { |
|
| 424 | + $this->rollback(); |
|
| 425 | + } |
|
| 417 | 426 | |
| 418 | 427 | $this->result = $this->transac_result; |
| 419 | 428 | |