@@ -16,10 +16,10 @@ |
||
| 16 | 16 | protected $timeFormat = '%2.5f'; |
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | - * @return mysqli |
|
| 20 | - * @throws Exceptions\ConnectException |
|
| 21 | - * @throws Exceptions\QueryException |
|
| 22 | - */ |
|
| 19 | + * @return mysqli |
|
| 20 | + * @throws Exceptions\ConnectException |
|
| 21 | + * @throws Exceptions\QueryException |
|
| 22 | + */ |
|
| 23 | 23 | abstract public function getConnect() : mysqli; |
| 24 | 24 | |
| 25 | 25 | /** |
@@ -200,14 +200,14 @@ |
||
| 200 | 200 | $out .= '<fieldset style="text-align:left">'; |
| 201 | 201 | $out .= '<legend>Query ' . $i . ' - ' . sprintf($this->timeFormat, $query['time']) . '</legend>'; |
| 202 | 202 | $out .= $query['sql'] . '<br><br>'; |
| 203 | - if (! empty($query['element'])) { |
|
| 203 | + if (!empty($query['element'])) { |
|
| 204 | 204 | $out .= $query['element']['type'] . ' => ' . $query['element']['name'] . '<br>'; |
| 205 | 205 | } |
| 206 | - if (! empty($query['event'])) { |
|
| 206 | + if (!empty($query['event'])) { |
|
| 207 | 207 | $out .= 'Current Event => ' . $query['event'] . '<br>'; |
| 208 | 208 | } |
| 209 | 209 | $out .= 'Affected Rows => ' . $query['rows'] . '<br>'; |
| 210 | - if (! empty($query['path'])) { |
|
| 210 | + if (!empty($query['path'])) { |
|
| 211 | 211 | $out .= 'Functions Path => ' . $query['path'] . '<br>'; |
| 212 | 212 | } |
| 213 | 213 | /*$out .= 'Functions Path => ' . $query['path']['method'] . '<br>'; |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | */ |
| 80 | 80 | public function getConnect() : mysqli |
| 81 | 81 | { |
| 82 | - if (! $this->isConnected()) { |
|
| 82 | + if (!$this->isConnected()) { |
|
| 83 | 83 | return $this->connect(); |
| 84 | 84 | } |
| 85 | 85 | |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | throw new Exceptions\ConnectException($this->conn->connect_error); |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - if (! $this->isConnected()) { |
|
| 109 | + if (!$this->isConnected()) { |
|
| 110 | 110 | throw new Exceptions\ConnectException( |
| 111 | 111 | $this->getLastError() ?: 'Failed to create the database connection!' |
| 112 | 112 | ); |
@@ -314,13 +314,12 @@ discard block |
||
| 314 | 314 | |
| 315 | 315 | if (\is_array($fields)) { |
| 316 | 316 | $useFields = empty($fromTable) ? |
| 317 | - $this->prepareValues($fields) : |
|
| 318 | - $this->prepareFields($fields, true); |
|
| 317 | + $this->prepareValues($fields) : $this->prepareFields($fields, true); |
|
| 319 | 318 | } else { |
| 320 | 319 | $useFields = $fields; |
| 321 | 320 | } |
| 322 | 321 | |
| 323 | - if (empty($useFields) || ! \is_scalar($useFields) || ($useFields === '*' && ! empty($fromTable))) { |
|
| 322 | + if (empty($useFields) || !\is_scalar($useFields) || ($useFields === '*' && !empty($fromTable))) { |
|
| 324 | 323 | throw (new Exceptions\InvalidFieldException('Invalid insert fields')) |
| 325 | 324 | ->setData($fields); |
| 326 | 325 | } |
@@ -367,7 +366,7 @@ discard block |
||
| 367 | 366 | $mode = 'insert'; |
| 368 | 367 | } else { |
| 369 | 368 | $result = $this->select('*', $table, $where); |
| 370 | - if (! $result instanceof mysqli_result) { |
|
| 369 | + if (!$result instanceof mysqli_result) { |
|
| 371 | 370 | throw (new Exceptions\QueryException('Need mysqli_result')) |
| 372 | 371 | ->setQuery($this->getLastQuery()); |
| 373 | 372 | } |
@@ -404,7 +403,7 @@ discard block |
||
| 404 | 403 | * @param int $col |
| 405 | 404 | * @return string|null |
| 406 | 405 | */ |
| 407 | - public function fieldName(mysqli_result $result, $col = 0) :? string |
|
| 406 | + public function fieldName(mysqli_result $result, $col = 0) : ? string |
|
| 408 | 407 | { |
| 409 | 408 | $field = $result->fetch_field_direct($col); |
| 410 | 409 | |
@@ -501,7 +500,7 @@ discard block |
||
| 501 | 500 | { |
| 502 | 501 | $col = []; |
| 503 | 502 | |
| 504 | - if (! ($result instanceof mysqli_result)) { |
|
| 503 | + if (!($result instanceof mysqli_result)) { |
|
| 505 | 504 | $result = $this->query($result); |
| 506 | 505 | } |
| 507 | 506 | |
@@ -525,7 +524,7 @@ discard block |
||
| 525 | 524 | { |
| 526 | 525 | $names = []; |
| 527 | 526 | |
| 528 | - if (! ($result instanceof mysqli_result)) { |
|
| 527 | + if (!($result instanceof mysqli_result)) { |
|
| 529 | 528 | $result = $this->query($result); |
| 530 | 529 | } |
| 531 | 530 | |
@@ -550,7 +549,7 @@ discard block |
||
| 550 | 549 | { |
| 551 | 550 | $out = false; |
| 552 | 551 | |
| 553 | - if (! ($result instanceof mysqli_result)) { |
|
| 552 | + if (!($result instanceof mysqli_result)) { |
|
| 554 | 553 | $result = $this->query($result); |
| 555 | 554 | } |
| 556 | 555 | |
@@ -572,7 +571,7 @@ discard block |
||
| 572 | 571 | public function getTableMetaData(string $table) : array |
| 573 | 572 | { |
| 574 | 573 | $metadata = []; |
| 575 | - if (! empty($table)) { |
|
| 574 | + if (!empty($table)) { |
|
| 576 | 575 | $sql = 'SHOW FIELDS FROM ' . $table; |
| 577 | 576 | $result = $this->query($sql); |
| 578 | 577 | if ($result instanceof mysqli_result) { |
@@ -51,11 +51,11 @@ discard block |
||
| 51 | 51 | protected function convertValue($value) |
| 52 | 52 | { |
| 53 | 53 | switch (true) { |
| 54 | - case (\is_numeric($value) && ! \is_float(1 * $value)): |
|
| 55 | - $value = (int)$value; |
|
| 54 | + case (\is_numeric($value) && !\is_float(1 * $value)): |
|
| 55 | + $value = (int) $value; |
|
| 56 | 56 | break; |
| 57 | - case \is_numeric($value) && \is_float(1*$value): |
|
| 58 | - $value = (float)$value; |
|
| 57 | + case \is_numeric($value) && \is_float(1 * $value): |
|
| 58 | + $value = (float) $value; |
|
| 59 | 59 | break; |
| 60 | 60 | default: |
| 61 | 61 | break; |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | public function convertDate(int $timestamp, string $fieldType = 'DATETIME') |
| 74 | 74 | { |
| 75 | 75 | $date = false; |
| 76 | - if (! empty($timestamp) && $timestamp > 0) { |
|
| 76 | + if (!empty($timestamp) && $timestamp > 0) { |
|
| 77 | 77 | switch ($fieldType) { |
| 78 | 78 | case 'DATE': |
| 79 | 79 | $date = date('Y-m-d', $timestamp); |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | if (\is_array($data)) { |
| 105 | 105 | $tmp = []; |
| 106 | 106 | foreach ($data as $alias => $field) { |
| 107 | - $tmp[] = ($alias !== $field && ! \is_int($alias) && $ignoreAlias === false) ? |
|
| 107 | + $tmp[] = ($alias !== $field && !\is_int($alias) && $ignoreAlias === false) ? |
|
| 108 | 108 | ($field . ' as `' . $alias . '`') : $field; |
| 109 | 109 | } |
| 110 | 110 | |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | } |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | - if (! \is_scalar($values)) { |
|
| 186 | + if (!\is_scalar($values)) { |
|
| 187 | 187 | throw (new Exceptions\InvalidFieldException('values')) |
| 188 | 188 | ->setData($values); |
| 189 | 189 | } |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | { |
| 228 | 228 | $onlyNumbers = true; |
| 229 | 229 | foreach ($data as $value) { |
| 230 | - if (! \is_numeric($value)) { |
|
| 230 | + if (!\is_numeric($value)) { |
|
| 231 | 231 | $onlyNumbers = false; |
| 232 | 232 | break; |
| 233 | 233 | } |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | } |
| 273 | 273 | $data = implode(' ', $tmp); |
| 274 | 274 | } |
| 275 | - if (! is_scalar($data) || empty($data)) { |
|
| 275 | + if (!is_scalar($data) || empty($data)) { |
|
| 276 | 276 | throw new Exceptions\TableNotDefinedException($data); |
| 277 | 277 | } |
| 278 | 278 | |
@@ -295,7 +295,7 @@ discard block |
||
| 295 | 295 | } |
| 296 | 296 | } |
| 297 | 297 | $data = trim($data); |
| 298 | - if (! empty($data) && stripos($data, 'WHERE') !== 0) { |
|
| 298 | + if (!empty($data) && stripos($data, 'WHERE') !== 0) { |
|
| 299 | 299 | $data = "WHERE {$data}"; |
| 300 | 300 | } |
| 301 | 301 | |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | protected function prepareOrder($data): string |
| 310 | 310 | { |
| 311 | 311 | $data = trim($data); |
| 312 | - if (! empty($data) && stripos($data, 'ORDER') !== 0) { |
|
| 312 | + if (!empty($data) && stripos($data, 'ORDER') !== 0) { |
|
| 313 | 313 | $data = "ORDER BY {$data}"; |
| 314 | 314 | } |
| 315 | 315 | |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | protected function prepareLimit($data): string |
| 324 | 324 | { |
| 325 | 325 | $data = trim($data); |
| 326 | - if (! empty($data) && stripos($data, 'LIMIT') !== 0) { |
|
| 326 | + if (!empty($data) && stripos($data, 'LIMIT') !== 0) { |
|
| 327 | 327 | $data = "LIMIT {$data}"; |
| 328 | 328 | } |
| 329 | 329 | |