@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | $this->rows = new \SplFixedArray($this->numRows); |
86 | 86 | |
87 | 87 | foreach ($rows as $key => $row) { |
88 | - $this->rows[ $key ] = new Result\Row($row); |
|
88 | + $this->rows[$key] = new Result\Row($row); |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | $this->seek(0); |
111 | 111 | |
112 | 112 | if ($this->count()) { |
113 | - return $this->rows[ $this->position ]; |
|
113 | + return $this->rows[$this->position]; |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | return new Row(); |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | $position = $this->count(); |
141 | 141 | } |
142 | 142 | |
143 | - if (isset($this->rows[ $position ])) { |
|
143 | + if (isset($this->rows[$position])) { |
|
144 | 144 | $this->position = $position; |
145 | 145 | } |
146 | 146 | } |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | $this->seek($this->count() - 1); |
179 | 179 | |
180 | 180 | if ($this->count()) { |
181 | - return $this->rows[ $this->position ]; |
|
181 | + return $this->rows[$this->position]; |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | return new Row(); |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | $this->seek($this->position); |
201 | 201 | |
202 | 202 | if ($this->count()) { |
203 | - return $this->rows[ $this->position ]; |
|
203 | + return $this->rows[$this->position]; |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | return new Row(); |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | public function valid() |
271 | 271 | { |
272 | 272 | if ($this->count()) { |
273 | - return isset($this->rows[ $this->position ]); |
|
273 | + return isset($this->rows[$this->position]); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | return false; |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | */ |
342 | 342 | public function offsetExists($offset) |
343 | 343 | { |
344 | - return (bool)isset($this->rows[ $offset ]); |
|
344 | + return (bool)isset($this->rows[$offset]); |
|
345 | 345 | } |
346 | 346 | |
347 | 347 | // ------------------------------------------------------------------------ |
@@ -362,8 +362,8 @@ discard block |
||
362 | 362 | */ |
363 | 363 | public function offsetGet($offset) |
364 | 364 | { |
365 | - if (isset($this->rows[ $offset ])) { |
|
366 | - return $this->rows[ $offset ]; |
|
365 | + if (isset($this->rows[$offset])) { |
|
366 | + return $this->rows[$offset]; |
|
367 | 367 | } |
368 | 368 | |
369 | 369 | return false; |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | public function offsetSet($offset, $value) |
392 | 392 | { |
393 | 393 | if ($value instanceof Row) { |
394 | - $this->rows[ $offset ] = $value; |
|
394 | + $this->rows[$offset] = $value; |
|
395 | 395 | } |
396 | 396 | } |
397 | 397 | |
@@ -413,8 +413,8 @@ discard block |
||
413 | 413 | */ |
414 | 414 | public function offsetUnset($offset) |
415 | 415 | { |
416 | - if (isset($this->rows[ $offset ])) { |
|
417 | - unset($this->rows[ $offset ]); |
|
416 | + if (isset($this->rows[$offset])) { |
|
417 | + unset($this->rows[$offset]); |
|
418 | 418 | } |
419 | 419 | } |
420 | 420 |
@@ -265,9 +265,9 @@ discard block |
||
265 | 265 | // No connection resource? Check if there is a failover else throw an error |
266 | 266 | if ( ! $this->handle) { |
267 | 267 | // Check if there is a failover set |
268 | - if ( ! empty($this->config[ 'failover' ]) && is_array($this->config[ 'failover' ])) { |
|
268 | + if ( ! empty($this->config['failover']) && is_array($this->config['failover'])) { |
|
269 | 269 | // Go over all the failovers |
270 | - foreach ($this->config[ 'failover' ] as $failover) { |
|
270 | + foreach ($this->config['failover'] as $failover) { |
|
271 | 271 | |
272 | 272 | // Try to connect |
273 | 273 | $this->platformConnectHandler($failover = new Config($failover)); |
@@ -338,11 +338,11 @@ discard block |
||
338 | 338 | */ |
339 | 339 | public function getPlatformInfo() |
340 | 340 | { |
341 | - if (isset($this->queriesResultCache[ 'platformInfo' ])) { |
|
342 | - return $this->queriesResultCache[ 'platformInfo' ]; |
|
341 | + if (isset($this->queriesResultCache['platformInfo'])) { |
|
342 | + return $this->queriesResultCache['platformInfo']; |
|
343 | 343 | } |
344 | 344 | |
345 | - return $this->queriesResultCache[ 'platformInfo' ] = $this->platformGetPlatformInfoHandler(); |
|
345 | + return $this->queriesResultCache['platformInfo'] = $this->platformGetPlatformInfoHandler(); |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | //-------------------------------------------------------------------- |
@@ -528,11 +528,11 @@ discard block |
||
528 | 528 | */ |
529 | 529 | final public function hasDatabase($databaseName) |
530 | 530 | { |
531 | - if (empty($this->queriesResultCache[ 'databaseNames' ])) { |
|
531 | + if (empty($this->queriesResultCache['databaseNames'])) { |
|
532 | 532 | $this->getDatabases(); |
533 | 533 | } |
534 | 534 | |
535 | - return (bool)in_array($databaseName, $this->queriesResultCache[ 'databaseNames' ]); |
|
535 | + return (bool)in_array($databaseName, $this->queriesResultCache['databaseNames']); |
|
536 | 536 | } |
537 | 537 | |
538 | 538 | //-------------------------------------------------------------------- |
@@ -558,7 +558,7 @@ discard block |
||
558 | 558 | */ |
559 | 559 | final public function setTablePrefix($tablePrefix) |
560 | 560 | { |
561 | - return $this->config[ 'tablePrefix' ] = $tablePrefix; |
|
561 | + return $this->config['tablePrefix'] = $tablePrefix; |
|
562 | 562 | } |
563 | 563 | |
564 | 564 | // ------------------------------------------------------------------------ |
@@ -577,11 +577,11 @@ discard block |
||
577 | 577 | { |
578 | 578 | $table = $this->prefixTable($table); |
579 | 579 | |
580 | - if (empty($this->queriesResultCache[ 'tableNames' ])) { |
|
580 | + if (empty($this->queriesResultCache['tableNames'])) { |
|
581 | 581 | $this->getTables(); |
582 | 582 | } |
583 | 583 | |
584 | - return (bool)in_array($table, $this->queriesResultCache[ 'tableNames' ]); |
|
584 | + return (bool)in_array($table, $this->queriesResultCache['tableNames']); |
|
585 | 585 | } |
586 | 586 | |
587 | 587 | // ------------------------------------------------------------------------ |
@@ -595,7 +595,7 @@ discard block |
||
595 | 595 | */ |
596 | 596 | final public function prefixTable($tableName) |
597 | 597 | { |
598 | - $tablePrefix = $this->config[ 'tablePrefix' ]; |
|
598 | + $tablePrefix = $this->config['tablePrefix']; |
|
599 | 599 | |
600 | 600 | if (empty($tablePrefix)) { |
601 | 601 | return $tableName; |
@@ -635,11 +635,11 @@ discard block |
||
635 | 635 | { |
636 | 636 | $table = $this->prefixTable($table); |
637 | 637 | |
638 | - if (empty($this->queriesResultCache[ 'tableColumns' ][ $table ])) { |
|
638 | + if (empty($this->queriesResultCache['tableColumns'][$table])) { |
|
639 | 639 | $this->getColumns($table); |
640 | 640 | } |
641 | 641 | |
642 | - return (bool)isset($this->queriesResultCache[ 'tableColumns' ][ $table ][ $column ]); |
|
642 | + return (bool)isset($this->queriesResultCache['tableColumns'][$table][$column]); |
|
643 | 643 | } |
644 | 644 | |
645 | 645 | // ------------------------------------------------------------------------ |
@@ -684,7 +684,7 @@ discard block |
||
684 | 684 | $queryStatement->setLastInsertId($this->getLastInsertId()); |
685 | 685 | |
686 | 686 | if ( ! array_key_exists($queryStatement->getKey(), $this->queriesCache)) { |
687 | - $this->queriesCache[ $queryStatement->getKey() ] = $queryStatement; |
|
687 | + $this->queriesCache[$queryStatement->getKey()] = $queryStatement; |
|
688 | 688 | } |
689 | 689 | |
690 | 690 | if ($queryStatement->hasErrors()) { |
@@ -851,7 +851,7 @@ discard block |
||
851 | 851 | $queryStatement->addHit(1); |
852 | 852 | |
853 | 853 | if ( ! array_key_exists($queryStatement->getKey(), $this->queriesCache)) { |
854 | - $this->queriesCache[ $queryStatement->getKey() ] = $queryStatement; |
|
854 | + $this->queriesCache[$queryStatement->getKey()] = $queryStatement; |
|
855 | 855 | } |
856 | 856 | |
857 | 857 | if ($queryStatement->hasErrors()) { |
@@ -891,8 +891,8 @@ discard block |
||
891 | 891 | { |
892 | 892 | $hasSqlBinders = strpos($sqlStatement, ':') !== false; |
893 | 893 | |
894 | - if (empty($binds) || empty($this->config[ 'bindMarker' ]) || |
|
895 | - (strpos($sqlStatement, $this->config[ 'bindMarker' ]) === false && |
|
894 | + if (empty($binds) || empty($this->config['bindMarker']) || |
|
895 | + (strpos($sqlStatement, $this->config['bindMarker']) === false && |
|
896 | 896 | $hasSqlBinders === false) |
897 | 897 | ) { |
898 | 898 | return $sqlStatement; |
@@ -913,7 +913,7 @@ discard block |
||
913 | 913 | } |
914 | 914 | |
915 | 915 | // We'll need marker length later |
916 | - $markerLength = strlen($this->config[ 'bindMarker' ]); |
|
916 | + $markerLength = strlen($this->config['bindMarker']); |
|
917 | 917 | |
918 | 918 | if ($hasSqlBinders) { |
919 | 919 | $sqlStatement = $this->replaceNamedBinds($sqlStatement, $sqlBinds); |
@@ -953,7 +953,7 @@ discard block |
||
953 | 953 | } elseif (strpos($bindReplace, ' AND ') !== false) { |
954 | 954 | $escapedValue = $bindReplace; |
955 | 955 | } else { |
956 | - $escapedValue = preg_quote(trim($escapedValue, $this->config[ 'escapeCharacter' ])); |
|
956 | + $escapedValue = preg_quote(trim($escapedValue, $this->config['escapeCharacter'])); |
|
957 | 957 | } |
958 | 958 | |
959 | 959 | if (preg_match("/\(.+?\)/", $bindSearch)) { |
@@ -1018,7 +1018,7 @@ discard block |
||
1018 | 1018 | { |
1019 | 1019 | if (is_array($string)) { |
1020 | 1020 | foreach ($string as $key => $value) { |
1021 | - $string[ $key ] = $this->escapeString($value, $like); |
|
1021 | + $string[$key] = $this->escapeString($value, $like); |
|
1022 | 1022 | } |
1023 | 1023 | |
1024 | 1024 | return $string; |
@@ -1029,11 +1029,11 @@ discard block |
||
1029 | 1029 | // escape LIKE condition wildcards |
1030 | 1030 | if ($like === true) { |
1031 | 1031 | $string = str_replace( |
1032 | - [$this->config[ 'likeEscapeCharacter' ], '%', '_'], |
|
1032 | + [$this->config['likeEscapeCharacter'], '%', '_'], |
|
1033 | 1033 | [ |
1034 | - $this->config[ 'likeEscapeCharacter' ] . $this->config[ 'likeEscapeCharacter' ], |
|
1035 | - $this->config[ 'likeEscapeCharacter' ] . '%', |
|
1036 | - $this->config[ 'likeEscapeCharacter' ] . '_', |
|
1034 | + $this->config['likeEscapeCharacter'] . $this->config['likeEscapeCharacter'], |
|
1035 | + $this->config['likeEscapeCharacter'] . '%', |
|
1036 | + $this->config['likeEscapeCharacter'] . '_', |
|
1037 | 1037 | ], |
1038 | 1038 | $string |
1039 | 1039 | ); |
@@ -1080,10 +1080,10 @@ discard block |
||
1080 | 1080 | // Make sure not to replace a chunk inside a string that happens to match the bind marker |
1081 | 1081 | if ($chunk = preg_match_all("/'[^']*'/i", $sqlStatement, $matches)) { |
1082 | 1082 | $chunk = preg_match_all( |
1083 | - '/' . preg_quote($this->config[ 'bindMarker' ], '/') . '/i', |
|
1083 | + '/' . preg_quote($this->config['bindMarker'], '/') . '/i', |
|
1084 | 1084 | str_replace( |
1085 | - $matches[ 0 ], |
|
1086 | - str_replace($this->config[ 'bindMarker' ], str_repeat(' ', $markerLength), $matches[ 0 ]), |
|
1085 | + $matches[0], |
|
1086 | + str_replace($this->config['bindMarker'], str_repeat(' ', $markerLength), $matches[0]), |
|
1087 | 1087 | $sqlStatement, |
1088 | 1088 | $chunk |
1089 | 1089 | ), |
@@ -1098,7 +1098,7 @@ discard block |
||
1098 | 1098 | } // Number of binds must match bindMarkers in the string. |
1099 | 1099 | else { |
1100 | 1100 | if (($chunk = preg_match_all( |
1101 | - '/' . preg_quote($this->config[ 'bindMarker' ], '/') . '/i', |
|
1101 | + '/' . preg_quote($this->config['bindMarker'], '/') . '/i', |
|
1102 | 1102 | $sqlStatement, |
1103 | 1103 | $matches, |
1104 | 1104 | PREG_OFFSET_CAPTURE |
@@ -1110,11 +1110,11 @@ discard block |
||
1110 | 1110 | |
1111 | 1111 | do { |
1112 | 1112 | $chunk--; |
1113 | - $escapedValue = $this->escape($sqlBinds[ $chunk ]); |
|
1113 | + $escapedValue = $this->escape($sqlBinds[$chunk]); |
|
1114 | 1114 | if (is_array($escapedValue)) { |
1115 | 1115 | $escapedValue = '(' . implode(',', $escapedValue) . ')'; |
1116 | 1116 | } |
1117 | - $sqlStatement = substr_replace($sqlStatement, $escapedValue, $matches[ 0 ][ $chunk ][ 1 ], $markerLength); |
|
1117 | + $sqlStatement = substr_replace($sqlStatement, $escapedValue, $matches[0][$chunk][1], $markerLength); |
|
1118 | 1118 | } while ($chunk !== 0); |
1119 | 1119 | |
1120 | 1120 | return $sqlStatement; |
@@ -1298,7 +1298,7 @@ discard block |
||
1298 | 1298 | if (is_array($item)) { |
1299 | 1299 | $escapedArray = []; |
1300 | 1300 | foreach ($item as $key => $value) { |
1301 | - $escapedArray[ $this->protectIdentifiers($key) ] = $this->protectIdentifiers( |
|
1301 | + $escapedArray[$this->protectIdentifiers($key)] = $this->protectIdentifiers( |
|
1302 | 1302 | $value, |
1303 | 1303 | $prefixSingle, |
1304 | 1304 | $protectIdentifiers, |
@@ -1356,11 +1356,11 @@ discard block |
||
1356 | 1356 | // |
1357 | 1357 | // NOTE: The ! empty() condition prevents this method |
1358 | 1358 | // from breaking when Query Builder isn't enabled. |
1359 | - if ( ! empty($aliasedTables) AND in_array($parts[ 0 ], $aliasedTables)) { |
|
1359 | + if ( ! empty($aliasedTables) AND in_array($parts[0], $aliasedTables)) { |
|
1360 | 1360 | if ($protectIdentifiers === true) { |
1361 | 1361 | foreach ($parts as $key => $val) { |
1362 | - if ( ! in_array($val, $this->config[ 'reservedIdentifiers' ])) { |
|
1363 | - $parts[ $key ] = $this->escapeIdentifiers($val); |
|
1362 | + if ( ! in_array($val, $this->config['reservedIdentifiers'])) { |
|
1363 | + $parts[$key] = $this->escapeIdentifiers($val); |
|
1364 | 1364 | } |
1365 | 1365 | } |
1366 | 1366 | |
@@ -1375,12 +1375,12 @@ discard block |
||
1375 | 1375 | // We now add the table prefix based on some logic. |
1376 | 1376 | // Do we have 4 segments (hostname.database.table.column)? |
1377 | 1377 | // If so, we add the table prefix to the column name in the 3rd segment. |
1378 | - if (isset($parts[ 3 ])) { |
|
1378 | + if (isset($parts[3])) { |
|
1379 | 1379 | $i = 2; |
1380 | 1380 | } |
1381 | 1381 | // Do we have 3 segments (database.table.column)? |
1382 | 1382 | // If so, we add the table prefix to the column name in 2nd position |
1383 | - elseif (isset($parts[ 2 ])) { |
|
1383 | + elseif (isset($parts[2])) { |
|
1384 | 1384 | $i = 1; |
1385 | 1385 | } |
1386 | 1386 | // Do we have 2 segments (table.column)? |
@@ -1396,15 +1396,15 @@ discard block |
||
1396 | 1396 | } |
1397 | 1397 | |
1398 | 1398 | // Verify table prefix and replace if necessary |
1399 | - if ($this->swapTablePrefix !== '' && strpos($parts[ $i ], $this->swapTablePrefix) === 0) { |
|
1400 | - $parts[ $i ] = preg_replace( |
|
1399 | + if ($this->swapTablePrefix !== '' && strpos($parts[$i], $this->swapTablePrefix) === 0) { |
|
1400 | + $parts[$i] = preg_replace( |
|
1401 | 1401 | '/^' . $this->swapTablePrefix . '(\S+?)/', |
1402 | 1402 | $this->config->tablePrefix . '\\1', |
1403 | - $parts[ $i ] |
|
1403 | + $parts[$i] |
|
1404 | 1404 | ); |
1405 | 1405 | } // We only add the table prefix if it does not already exist |
1406 | - elseif (strpos($parts[ $i ], $this->config->tablePrefix) !== 0) { |
|
1407 | - $parts[ $i ] = $this->config->tablePrefix . $parts[ $i ]; |
|
1406 | + elseif (strpos($parts[$i], $this->config->tablePrefix) !== 0) { |
|
1407 | + $parts[$i] = $this->config->tablePrefix . $parts[$i]; |
|
1408 | 1408 | } |
1409 | 1409 | |
1410 | 1410 | // Put the parts back together |
@@ -1421,7 +1421,7 @@ discard block |
||
1421 | 1421 | // In some cases, especially 'from', we end up running through |
1422 | 1422 | // protect_identifiers twice. This algorithm won't work when |
1423 | 1423 | // it contains the escapeChar so strip it out. |
1424 | - $item = trim($item, $this->config[ 'escapeCharacter' ]); |
|
1424 | + $item = trim($item, $this->config['escapeCharacter']); |
|
1425 | 1425 | |
1426 | 1426 | // Is there a table prefix? If not, no need to insert it |
1427 | 1427 | if ($this->config->tablePrefix !== '') { |
@@ -1438,7 +1438,7 @@ discard block |
||
1438 | 1438 | } |
1439 | 1439 | } |
1440 | 1440 | |
1441 | - if ($protectIdentifiers === true && ! in_array($item, $this->config[ 'reservedIdentifiers' ])) { |
|
1441 | + if ($protectIdentifiers === true && ! in_array($item, $this->config['reservedIdentifiers'])) { |
|
1442 | 1442 | $item = $this->escapeIdentifiers($item); |
1443 | 1443 | } |
1444 | 1444 | |
@@ -1460,22 +1460,22 @@ discard block |
||
1460 | 1460 | */ |
1461 | 1461 | final public function escapeIdentifiers($item) |
1462 | 1462 | { |
1463 | - if ($this->config[ 'escapeCharacter' ] === '' OR empty($item) OR in_array( |
|
1463 | + if ($this->config['escapeCharacter'] === '' OR empty($item) OR in_array( |
|
1464 | 1464 | $item, |
1465 | - $this->config[ 'reservedIdentifiers' ] |
|
1465 | + $this->config['reservedIdentifiers'] |
|
1466 | 1466 | ) |
1467 | 1467 | ) { |
1468 | 1468 | return $item; |
1469 | 1469 | } elseif (is_array($item)) { |
1470 | 1470 | foreach ($item as $key => $value) { |
1471 | - $item[ $key ] = $this->escapeIdentifiers($value); |
|
1471 | + $item[$key] = $this->escapeIdentifiers($value); |
|
1472 | 1472 | } |
1473 | 1473 | |
1474 | 1474 | return $item; |
1475 | 1475 | } // Avoid breaking functions and literal values inside queries |
1476 | 1476 | elseif (ctype_digit( |
1477 | 1477 | $item |
1478 | - ) OR $item[ 0 ] === "'" OR ($this->config[ 'escapeCharacter' ] !== '"' && $item[ 0 ] === '"') OR |
|
1478 | + ) OR $item[0] === "'" OR ($this->config['escapeCharacter'] !== '"' && $item[0] === '"') OR |
|
1479 | 1479 | strpos($item, '(') !== false |
1480 | 1480 | ) { |
1481 | 1481 | return $item; |
@@ -1484,31 +1484,31 @@ discard block |
||
1484 | 1484 | static $pregEscapeCharacters = []; |
1485 | 1485 | |
1486 | 1486 | if (empty($pregEscapeCharacters)) { |
1487 | - if (is_array($this->config[ 'escapeCharacter' ])) { |
|
1487 | + if (is_array($this->config['escapeCharacter'])) { |
|
1488 | 1488 | $pregEscapeCharacters = [ |
1489 | - preg_quote($this->config[ 'escapeCharacter' ][ 0 ], '/'), |
|
1490 | - preg_quote($this->config[ 'escapeCharacter' ][ 1 ], '/'), |
|
1491 | - $this->config[ 'escapeCharacter' ][ 0 ], |
|
1492 | - $this->config[ 'escapeCharacter' ][ 1 ], |
|
1489 | + preg_quote($this->config['escapeCharacter'][0], '/'), |
|
1490 | + preg_quote($this->config['escapeCharacter'][1], '/'), |
|
1491 | + $this->config['escapeCharacter'][0], |
|
1492 | + $this->config['escapeCharacter'][1], |
|
1493 | 1493 | ]; |
1494 | 1494 | } else { |
1495 | - $pregEscapeCharacters[ 0 ] |
|
1496 | - = $pregEscapeCharacters[ 1 ] = preg_quote($this->config[ 'escapeCharacter' ], '/'); |
|
1497 | - $pregEscapeCharacters[ 2 ] = $pregEscapeCharacters[ 3 ] = $this->config[ 'escapeCharacter' ]; |
|
1495 | + $pregEscapeCharacters[0] |
|
1496 | + = $pregEscapeCharacters[1] = preg_quote($this->config['escapeCharacter'], '/'); |
|
1497 | + $pregEscapeCharacters[2] = $pregEscapeCharacters[3] = $this->config['escapeCharacter']; |
|
1498 | 1498 | } |
1499 | 1499 | } |
1500 | 1500 | |
1501 | - foreach ($this->config[ 'reservedIdentifiers' ] as $id) { |
|
1501 | + foreach ($this->config['reservedIdentifiers'] as $id) { |
|
1502 | 1502 | if (strpos($item, '.' . $id) !== false) { |
1503 | 1503 | return preg_replace( |
1504 | 1504 | '/' |
1505 | - . $pregEscapeCharacters[ 0 ] |
|
1505 | + . $pregEscapeCharacters[0] |
|
1506 | 1506 | . '?([^' |
1507 | - . $pregEscapeCharacters[ 1 ] |
|
1507 | + . $pregEscapeCharacters[1] |
|
1508 | 1508 | . '\.]+)' |
1509 | - . $pregEscapeCharacters[ 1 ] |
|
1509 | + . $pregEscapeCharacters[1] |
|
1510 | 1510 | . '?\./i', |
1511 | - $pregEscapeCharacters[ 2 ] . '$1' . $pregEscapeCharacters[ 3 ] . '.', |
|
1511 | + $pregEscapeCharacters[2] . '$1' . $pregEscapeCharacters[3] . '.', |
|
1512 | 1512 | $item |
1513 | 1513 | ); |
1514 | 1514 | } |
@@ -1516,13 +1516,13 @@ discard block |
||
1516 | 1516 | |
1517 | 1517 | return preg_replace( |
1518 | 1518 | '/' |
1519 | - . $pregEscapeCharacters[ 0 ] |
|
1519 | + . $pregEscapeCharacters[0] |
|
1520 | 1520 | . '?([^' |
1521 | - . $pregEscapeCharacters[ 1 ] |
|
1521 | + . $pregEscapeCharacters[1] |
|
1522 | 1522 | . '\.]+)' |
1523 | - . $pregEscapeCharacters[ 1 ] |
|
1523 | + . $pregEscapeCharacters[1] |
|
1524 | 1524 | . '?(\.)?/i', |
1525 | - $pregEscapeCharacters[ 2 ] . '$1' . $pregEscapeCharacters[ 3 ] . '$2', |
|
1525 | + $pregEscapeCharacters[2] . '$1' . $pregEscapeCharacters[3] . '$2', |
|
1526 | 1526 | $item |
1527 | 1527 | ); |
1528 | 1528 | } |
@@ -125,18 +125,18 @@ discard block |
||
125 | 125 | */ |
126 | 126 | public function getDatabases() |
127 | 127 | { |
128 | - if (empty($this->queriesResultCache[ 'databaseNames' ])) { |
|
128 | + if (empty($this->queriesResultCache['databaseNames'])) { |
|
129 | 129 | $result = $this->query('SHOW DATABASES'); |
130 | 130 | |
131 | 131 | if ($result->count()) { |
132 | 132 | foreach ($result as $row) { |
133 | 133 | |
134 | 134 | if ( ! isset($key)) { |
135 | - if (isset($row[ 'database' ])) { |
|
135 | + if (isset($row['database'])) { |
|
136 | 136 | $key = 'database'; |
137 | - } elseif (isset($row[ 'Database' ])) { |
|
137 | + } elseif (isset($row['Database'])) { |
|
138 | 138 | $key = 'Database'; |
139 | - } elseif (isset($row[ 'DATABASE' ])) { |
|
139 | + } elseif (isset($row['DATABASE'])) { |
|
140 | 140 | $key = 'DATABASE'; |
141 | 141 | } else { |
142 | 142 | /* We have no other choice but to just get the first element's key. |
@@ -149,12 +149,12 @@ discard block |
||
149 | 149 | } |
150 | 150 | } |
151 | 151 | |
152 | - $this->queriesResultCache[ 'databaseNames' ][] = $row->offsetGet($key); |
|
152 | + $this->queriesResultCache['databaseNames'][] = $row->offsetGet($key); |
|
153 | 153 | } |
154 | 154 | } |
155 | 155 | } |
156 | 156 | |
157 | - return $this->queriesResultCache[ 'databaseNames' ]; |
|
157 | + return $this->queriesResultCache['databaseNames']; |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | // ------------------------------------------------------------------------ |
@@ -172,12 +172,12 @@ discard block |
||
172 | 172 | */ |
173 | 173 | public function getTables($prefixLimit = false) |
174 | 174 | { |
175 | - if (empty($this->queriesResultCache[ 'tableNames' ])) { |
|
175 | + if (empty($this->queriesResultCache['tableNames'])) { |
|
176 | 176 | |
177 | - $sqlStatement = 'SHOW TABLES FROM ' . $this->escapeIdentifiers($this->config[ 'database' ]); |
|
177 | + $sqlStatement = 'SHOW TABLES FROM ' . $this->escapeIdentifiers($this->config['database']); |
|
178 | 178 | |
179 | - if ($prefixLimit !== false && $this->config[ 'tablePrefix' ] !== '') { |
|
180 | - $sqlStatement .= " LIKE '" . $this->escapeLikeString($this->config[ 'tablePrefix' ]) . "%'"; |
|
179 | + if ($prefixLimit !== false && $this->config['tablePrefix'] !== '') { |
|
180 | + $sqlStatement .= " LIKE '" . $this->escapeLikeString($this->config['tablePrefix']) . "%'"; |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | $result = $this->query($sqlStatement); |
@@ -186,9 +186,9 @@ discard block |
||
186 | 186 | foreach ($result as $row) { |
187 | 187 | // Do we know from which column to get the table name? |
188 | 188 | if ( ! isset($key)) { |
189 | - if (isset($row[ 'table_name' ])) { |
|
189 | + if (isset($row['table_name'])) { |
|
190 | 190 | $key = 'table_name'; |
191 | - } elseif (isset($row[ 'TABLE_NAME' ])) { |
|
191 | + } elseif (isset($row['TABLE_NAME'])) { |
|
192 | 192 | $key = 'TABLE_NAME'; |
193 | 193 | } else { |
194 | 194 | /* We have no other choice but to just get the first element's key. |
@@ -201,12 +201,12 @@ discard block |
||
201 | 201 | } |
202 | 202 | } |
203 | 203 | |
204 | - $this->queriesResultCache[ 'tableNames' ][] = $row->offsetGet($key); |
|
204 | + $this->queriesResultCache['tableNames'][] = $row->offsetGet($key); |
|
205 | 205 | } |
206 | 206 | } |
207 | 207 | } |
208 | 208 | |
209 | - return $this->queriesResultCache[ 'tableNames' ]; |
|
209 | + return $this->queriesResultCache['tableNames']; |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | // ------------------------------------------------------------------------ |
@@ -224,16 +224,16 @@ discard block |
||
224 | 224 | { |
225 | 225 | $table = $this->prefixTable($table); |
226 | 226 | |
227 | - if (empty($this->queriesResultCache[ 'tableColumns' ][ $table ])) { |
|
227 | + if (empty($this->queriesResultCache['tableColumns'][$table])) { |
|
228 | 228 | $result = $this->query('SHOW COLUMNS FROM ' . $this->protectIdentifiers($table, true, null, false)); |
229 | 229 | |
230 | 230 | if ($result->count()) { |
231 | 231 | foreach ($result as $row) { |
232 | 232 | // Do we know from where to get the column's name? |
233 | 233 | if ( ! isset($key)) { |
234 | - if (isset($row[ 'column_name' ])) { |
|
234 | + if (isset($row['column_name'])) { |
|
235 | 235 | $key = 'column_name'; |
236 | - } elseif (isset($row[ 'COLUMN_NAME' ])) { |
|
236 | + } elseif (isset($row['COLUMN_NAME'])) { |
|
237 | 237 | $key = 'COLUMN_NAME'; |
238 | 238 | } else { |
239 | 239 | /* We have no other choice but to just get the first element's key. |
@@ -246,12 +246,12 @@ discard block |
||
246 | 246 | } |
247 | 247 | } |
248 | 248 | |
249 | - $this->queriesResultCache[ 'tableColumns' ][ $table ][ $row->offsetGet($key) ] = $row; |
|
249 | + $this->queriesResultCache['tableColumns'][$table][$row->offsetGet($key)] = $row; |
|
250 | 250 | } |
251 | 251 | } |
252 | 252 | } |
253 | 253 | |
254 | - return $this->queriesResultCache[ 'tableColumns' ][ $table ]; |
|
254 | + return $this->queriesResultCache['tableColumns'][$table]; |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | // ------------------------------------------------------------------------ |
@@ -330,13 +330,13 @@ discard block |
||
330 | 330 | */ |
331 | 331 | protected function platformGetPlatformInfoHandler() |
332 | 332 | { |
333 | - $server[ 'version' ][ 'string' ] = $this->handle->server_info; |
|
334 | - $server[ 'version' ][ 'number' ] = $this->handle->server_version; |
|
335 | - $server[ 'stats' ] = $this->handle->get_connection_stats(); |
|
333 | + $server['version']['string'] = $this->handle->server_info; |
|
334 | + $server['version']['number'] = $this->handle->server_version; |
|
335 | + $server['stats'] = $this->handle->get_connection_stats(); |
|
336 | 336 | |
337 | - $client[ 'version' ][ 'string' ] = $this->handle->client_info; |
|
338 | - $client[ 'version' ][ 'number' ] = $this->handle->client_version; |
|
339 | - $client[ 'stats' ] = mysqli_get_client_stats(); |
|
337 | + $client['version']['string'] = $this->handle->client_info; |
|
338 | + $client['version']['number'] = $this->handle->client_version; |
|
339 | + $client['stats'] = mysqli_get_client_stats(); |
|
340 | 340 | |
341 | 341 | return new SplArrayObject([ |
342 | 342 | 'name' => $this->getPlatform(), |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | protected function platformConnectHandler(Config $config) |
364 | 364 | { |
365 | 365 | // Do we have a socket path? |
366 | - if ($config->hostname[ 0 ] === '/') { |
|
366 | + if ($config->hostname[0] === '/') { |
|
367 | 367 | $hostname = null; |
368 | 368 | $port = null; |
369 | 369 | $socket = $config->hostname; |
@@ -409,15 +409,15 @@ discard block |
||
409 | 409 | |
410 | 410 | if (is_array($config->encrypt)) { |
411 | 411 | $ssl = []; |
412 | - empty($config->encrypt[ 'ssl_key' ]) OR $ssl[ 'key' ] = $config->encrypt[ 'ssl_key' ]; |
|
413 | - empty($config->encrypt[ 'ssl_cert' ]) OR $ssl[ 'cert' ] = $config->encrypt[ 'ssl_cert' ]; |
|
414 | - empty($config->encrypt[ 'ssl_ca' ]) OR $ssl[ 'ca' ] = $config->encrypt[ 'ssl_ca' ]; |
|
415 | - empty($config->encrypt[ 'ssl_capath' ]) OR $ssl[ 'capath' ] = $config->encrypt[ 'ssl_capath' ]; |
|
416 | - empty($config->encrypt[ 'ssl_cipher' ]) OR $ssl[ 'cipher' ] = $config->encrypt[ 'ssl_cipher' ]; |
|
412 | + empty($config->encrypt['ssl_key']) OR $ssl['key'] = $config->encrypt['ssl_key']; |
|
413 | + empty($config->encrypt['ssl_cert']) OR $ssl['cert'] = $config->encrypt['ssl_cert']; |
|
414 | + empty($config->encrypt['ssl_ca']) OR $ssl['ca'] = $config->encrypt['ssl_ca']; |
|
415 | + empty($config->encrypt['ssl_capath']) OR $ssl['capath'] = $config->encrypt['ssl_capath']; |
|
416 | + empty($config->encrypt['ssl_cipher']) OR $ssl['cipher'] = $config->encrypt['ssl_cipher']; |
|
417 | 417 | |
418 | 418 | if ( ! empty($ssl)) { |
419 | - if (isset($config->encrypt[ 'ssl_verify' ])) { |
|
420 | - if ($config->encrypt[ 'ssl_verify' ]) { |
|
419 | + if (isset($config->encrypt['ssl_verify'])) { |
|
420 | + if ($config->encrypt['ssl_verify']) { |
|
421 | 421 | defined('MYSQLI_OPT_SSL_VERIFY_SERVER_CERT') |
422 | 422 | && $this->handle->options(MYSQLI_OPT_SSL_VERIFY_SERVER_CERT, true); |
423 | 423 | } |
@@ -434,20 +434,20 @@ discard block |
||
434 | 434 | |
435 | 435 | $flags |= MYSQLI_CLIENT_SSL; |
436 | 436 | $this->handle->ssl_set( |
437 | - isset($ssl[ 'key' ]) |
|
438 | - ? $ssl[ 'key' ] |
|
437 | + isset($ssl['key']) |
|
438 | + ? $ssl['key'] |
|
439 | 439 | : null, |
440 | - isset($ssl[ 'cert' ]) |
|
441 | - ? $ssl[ 'cert' ] |
|
440 | + isset($ssl['cert']) |
|
441 | + ? $ssl['cert'] |
|
442 | 442 | : null, |
443 | - isset($ssl[ 'ca' ]) |
|
444 | - ? $ssl[ 'ca' ] |
|
443 | + isset($ssl['ca']) |
|
444 | + ? $ssl['ca'] |
|
445 | 445 | : null, |
446 | - isset($ssl[ 'capath' ]) |
|
447 | - ? $ssl[ 'capath' ] |
|
446 | + isset($ssl['capath']) |
|
447 | + ? $ssl['capath'] |
|
448 | 448 | : null, |
449 | - isset($ssl[ 'cipher' ]) |
|
450 | - ? $ssl[ 'cipher' ] |
|
449 | + isset($ssl['cipher']) |
|
450 | + ? $ssl['cipher'] |
|
451 | 451 | : null |
452 | 452 | ); |
453 | 453 | } |
@@ -139,11 +139,11 @@ |
||
139 | 139 | $columns = []; |
140 | 140 | |
141 | 141 | foreach ($values as $key => $value) { |
142 | - $ids[] = $value[ $index ]; |
|
142 | + $ids[] = $value[$index]; |
|
143 | 143 | |
144 | 144 | foreach (array_keys($value) as $field) { |
145 | 145 | if ($field !== $index) { |
146 | - $columns[ $field ][] = 'WHEN ' . $index . ' = ' . $value[ $index ] . ' THEN ' . $value[ $field ]; |
|
146 | + $columns[$field][] = 'WHEN ' . $index . ' = ' . $value[$index] . ' THEN ' . $value[$field]; |
|
147 | 147 | } |
148 | 148 | } |
149 | 149 | } |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | */ |
102 | 102 | public function __construct(AbstractConnection &$conn) |
103 | 103 | { |
104 | - $this->conn =& $conn; |
|
104 | + $this->conn = & $conn; |
|
105 | 105 | $this->builderCache = new QueryBuilderCache(); |
106 | 106 | $this->cacheMode = $this->conn->getConfig('cacheEnable'); |
107 | 107 | } |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | $alias = empty($alias) |
283 | 283 | ? strtolower($type) . '_' . $field |
284 | 284 | : $alias; |
285 | - $sqlStatement = sprintf($SqlAggregateFunctions[ $type ], $field) |
|
285 | + $sqlStatement = sprintf($SqlAggregateFunctions[$type], $field) |
|
286 | 286 | . ' AS ' |
287 | 287 | . $this->conn->escapeIdentifiers($alias); |
288 | 288 | |
@@ -337,11 +337,11 @@ discard block |
||
337 | 337 | |
338 | 338 | for ($i = 0; $i < $countFieldAlias; $i++) { |
339 | 339 | if ($i == 0) { |
340 | - $fieldAlias[ $i ] = $fieldAlias[ $i ] . "'+"; |
|
340 | + $fieldAlias[$i] = $fieldAlias[$i] . "'+"; |
|
341 | 341 | } elseif ($i == ($countFieldAlias - 1)) { |
342 | - $fieldAlias[ $i ] = "'+" . $fieldAlias[ $i ]; |
|
342 | + $fieldAlias[$i] = "'+" . $fieldAlias[$i]; |
|
343 | 343 | } else { |
344 | - $fieldAlias[ $i ] = "'+" . $fieldAlias[ $i ] . "'+"; |
|
344 | + $fieldAlias[$i] = "'+" . $fieldAlias[$i] . "'+"; |
|
345 | 345 | } |
346 | 346 | } |
347 | 347 | |
@@ -493,7 +493,7 @@ discard block |
||
493 | 493 | |
494 | 494 | $this->select( |
495 | 495 | sprintf( |
496 | - $SqlScalarFunctions[ $type ], |
|
496 | + $SqlScalarFunctions[$type], |
|
497 | 497 | $field, |
498 | 498 | $this->conn->escapeIdentifiers($alias) |
499 | 499 | ) |
@@ -698,7 +698,7 @@ discard block |
||
698 | 698 | |
699 | 699 | if (is_array($field)) { |
700 | 700 | $fieldName = key($field); |
701 | - $fieldAlias = $field[ $fieldName ]; |
|
701 | + $fieldAlias = $field[$fieldName]; |
|
702 | 702 | } elseif (strpos($field, ' AS ') !== false) { |
703 | 703 | $xField = explode(' AS ', $field); |
704 | 704 | $xField = array_map('trim', $xField); |
@@ -905,7 +905,7 @@ discard block |
||
905 | 905 | public function dateDiff(array $fields, $alias) |
906 | 906 | { |
907 | 907 | $dateTimeStart = key($fields); |
908 | - $dateTimeEnd = $fields[ $dateTimeStart ]; |
|
908 | + $dateTimeEnd = $fields[$dateTimeStart]; |
|
909 | 909 | |
910 | 910 | if (preg_match("/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/", $dateTimeStart)) { |
911 | 911 | $dateTimeStart = $this->conn->escape($dateTimeStart); |
@@ -979,7 +979,7 @@ discard block |
||
979 | 979 | |
980 | 980 | $this->builderCache->from[] = $this->conn->protectIdentifiers($name, true, null, false); |
981 | 981 | } |
982 | - } elseif(is_array($table)) { |
|
982 | + } elseif (is_array($table)) { |
|
983 | 983 | foreach ($table as $alias => $name) { |
984 | 984 | $name = trim($name) . ' AS ' . trim($alias); |
985 | 985 | |
@@ -1099,14 +1099,14 @@ discard block |
||
1099 | 1099 | // Split multiple conditions |
1100 | 1100 | if (preg_match_all('/\sAND\s|\sOR\s/i', $condition, $joints, PREG_OFFSET_CAPTURE)) { |
1101 | 1101 | $conditions = []; |
1102 | - $joints = $joints[ 0 ]; |
|
1102 | + $joints = $joints[0]; |
|
1103 | 1103 | array_unshift($joints, ['', 0]); |
1104 | 1104 | |
1105 | 1105 | for ($i = count($joints) - 1, $pos = strlen($condition); $i >= 0; $i--) { |
1106 | - $joints[ $i ][ 1 ] += strlen($joints[ $i ][ 0 ]); // offset |
|
1107 | - $conditions[ $i ] = substr($condition, $joints[ $i ][ 1 ], $pos - $joints[ $i ][ 1 ]); |
|
1108 | - $pos = $joints[ $i ][ 1 ] - strlen($joints[ $i ][ 0 ]); |
|
1109 | - $joints[ $i ] = $joints[ $i ][ 0 ]; |
|
1106 | + $joints[$i][1] += strlen($joints[$i][0]); // offset |
|
1107 | + $conditions[$i] = substr($condition, $joints[$i][1], $pos - $joints[$i][1]); |
|
1108 | + $pos = $joints[$i][1] - strlen($joints[$i][0]); |
|
1109 | + $joints[$i] = $joints[$i][0]; |
|
1110 | 1110 | } |
1111 | 1111 | } else { |
1112 | 1112 | $conditions = [$condition]; |
@@ -1115,17 +1115,17 @@ discard block |
||
1115 | 1115 | |
1116 | 1116 | $condition = ' ON '; |
1117 | 1117 | for ($i = 0, $c = count($conditions); $i < $c; $i++) { |
1118 | - $operator = $this->getOperator($conditions[ $i ]); |
|
1119 | - $condition .= $joints[ $i ]; |
|
1118 | + $operator = $this->getOperator($conditions[$i]); |
|
1119 | + $condition .= $joints[$i]; |
|
1120 | 1120 | $condition .= preg_match( |
1121 | 1121 | "/(\(*)?([\[\]\w\.'-]+)" . preg_quote($operator) . "(.*)/i", |
1122 | - $conditions[ $i ], |
|
1122 | + $conditions[$i], |
|
1123 | 1123 | $match |
1124 | 1124 | ) |
1125 | - ? $match[ 1 ] . $this->conn->protectIdentifiers( |
|
1126 | - $match[ 2 ] |
|
1127 | - ) . $operator . $this->conn->protectIdentifiers($match[ 3 ]) |
|
1128 | - : $conditions[ $i ]; |
|
1125 | + ? $match[1] . $this->conn->protectIdentifiers( |
|
1126 | + $match[2] |
|
1127 | + ) . $operator . $this->conn->protectIdentifiers($match[3]) |
|
1128 | + : $conditions[$i]; |
|
1129 | 1129 | } |
1130 | 1130 | } |
1131 | 1131 | |
@@ -1189,23 +1189,23 @@ discard block |
||
1189 | 1189 | : ''; |
1190 | 1190 | |
1191 | 1191 | $operator = [ |
1192 | - '\s*(?:<|>|!)?=\s*', // =, <=, >=, != |
|
1193 | - '\s*<>?\s*', // <, <> |
|
1194 | - '\s*>\s*', // > |
|
1195 | - '\s+IS NULL', // IS NULL |
|
1196 | - '\s+IS NOT NULL', // IS NOT NULL |
|
1197 | - '\s+EXISTS\s*\(.*\)', // EXISTS(Sql) |
|
1198 | - '\s+NOT EXISTS\s*\(.*\)', // NOT EXISTS(Sql) |
|
1199 | - '\s+BETWEEN\s+', // BETWEEN value AND value |
|
1200 | - '\s+IN\s*\(.*\)', // IN(list) |
|
1201 | - '\s+NOT IN\s*\(.*\)', // NOT IN (list) |
|
1202 | - '\s+LIKE\s+\S.*(' . $likeEscapeString . ')?', // LIKE 'expr'[ ESCAPE '%s'] |
|
1192 | + '\s*(?:<|>|!)?=\s*', // =, <=, >=, != |
|
1193 | + '\s*<>?\s*', // <, <> |
|
1194 | + '\s*>\s*', // > |
|
1195 | + '\s+IS NULL', // IS NULL |
|
1196 | + '\s+IS NOT NULL', // IS NOT NULL |
|
1197 | + '\s+EXISTS\s*\(.*\)', // EXISTS(Sql) |
|
1198 | + '\s+NOT EXISTS\s*\(.*\)', // NOT EXISTS(Sql) |
|
1199 | + '\s+BETWEEN\s+', // BETWEEN value AND value |
|
1200 | + '\s+IN\s*\(.*\)', // IN(list) |
|
1201 | + '\s+NOT IN\s*\(.*\)', // NOT IN (list) |
|
1202 | + '\s+LIKE\s+\S.*(' . $likeEscapeString . ')?', // LIKE 'expr'[ ESCAPE '%s'] |
|
1203 | 1203 | '\s+NOT LIKE\s+\S.*(' . $likeEscapeString . ')?' // NOT LIKE 'expr'[ ESCAPE '%s'] |
1204 | 1204 | ]; |
1205 | 1205 | } |
1206 | 1206 | |
1207 | 1207 | return preg_match('/' . implode('|', $operator) . '/i', $string, $match) |
1208 | - ? $match[ 0 ] |
|
1208 | + ? $match[0] |
|
1209 | 1209 | : false; |
1210 | 1210 | } |
1211 | 1211 | |
@@ -1275,8 +1275,8 @@ discard block |
||
1275 | 1275 | $fieldName = substr( |
1276 | 1276 | $fieldName, |
1277 | 1277 | 0, |
1278 | - $match[ 0 ][ 1 ] |
|
1279 | - ) . ($match[ 1 ][ 0 ] === '=' |
|
1278 | + $match[0][1] |
|
1279 | + ) . ($match[1][0] === '=' |
|
1280 | 1280 | ? ' IS NULL' |
1281 | 1281 | : ' IS NOT NULL'); |
1282 | 1282 | } elseif ($fieldValue instanceof AbstractQueryBuilder) { |
@@ -1332,7 +1332,7 @@ discard block |
||
1332 | 1332 | public function bind($field, $value) |
1333 | 1333 | { |
1334 | 1334 | if ( ! array_key_exists($field, $this->builderCache->binds)) { |
1335 | - $this->builderCache->binds[ $field ] = $value; |
|
1335 | + $this->builderCache->binds[$field] = $value; |
|
1336 | 1336 | |
1337 | 1337 | return $field; |
1338 | 1338 | } |
@@ -1343,7 +1343,7 @@ discard block |
||
1343 | 1343 | ++$count; |
1344 | 1344 | } |
1345 | 1345 | |
1346 | - $this->builderCache->binds[ $field . '_' . $count ] = $value; |
|
1346 | + $this->builderCache->binds[$field . '_' . $count] = $value; |
|
1347 | 1347 | |
1348 | 1348 | return $field . '_' . $count; |
1349 | 1349 | } |
@@ -1876,8 +1876,8 @@ discard block |
||
1876 | 1876 | |
1877 | 1877 | // Do we have a seed value? |
1878 | 1878 | $fields = ctype_digit((string)$fields) |
1879 | - ? sprintf($this->SqlOrderByRandomKeywords[ 1 ], $fields) |
|
1880 | - : $this->SqlOrderByRandomKeywords[ 0 ]; |
|
1879 | + ? sprintf($this->SqlOrderByRandomKeywords[1], $fields) |
|
1880 | + : $this->SqlOrderByRandomKeywords[0]; |
|
1881 | 1881 | } elseif (empty($fields)) { |
1882 | 1882 | return $this; |
1883 | 1883 | } elseif ($direction !== '') { |
@@ -1905,8 +1905,8 @@ discard block |
||
1905 | 1905 | PREG_OFFSET_CAPTURE |
1906 | 1906 | )) |
1907 | 1907 | ? [ |
1908 | - 'field' => ltrim(substr($fields, 0, $match[ 0 ][ 1 ])), |
|
1909 | - 'direction' => ' ' . $match[ 1 ][ 0 ], |
|
1908 | + 'field' => ltrim(substr($fields, 0, $match[0][1])), |
|
1909 | + 'direction' => ' ' . $match[1][0], |
|
1910 | 1910 | 'escape' => true, |
1911 | 1911 | ] |
1912 | 1912 | : ['field' => trim($fields), 'direction' => $direction, 'escape' => true]; |
@@ -2325,7 +2325,7 @@ discard block |
||
2325 | 2325 | if (count($this->builderCache->sets)) { |
2326 | 2326 | $sqlStatement = $this->platformInsertStatement( |
2327 | 2327 | $this->conn->protectIdentifiers( |
2328 | - $this->builderCache->from[ 0 ], |
|
2328 | + $this->builderCache->from[0], |
|
2329 | 2329 | true, |
2330 | 2330 | $escape, |
2331 | 2331 | false |
@@ -2374,7 +2374,7 @@ discard block |
||
2374 | 2374 | foreach ($field as $key => $value) { |
2375 | 2375 | if ($key === 'birthday' || $key === 'date') { |
2376 | 2376 | if (is_array($value)) { |
2377 | - $value = $value[ 'year' ] . '-' . $value[ 'month' ] . '-' . $value[ 'date' ]; |
|
2377 | + $value = $value['year'] . '-' . $value['month'] . '-' . $value['date']; |
|
2378 | 2378 | } elseif (is_object($value)) { |
2379 | 2379 | $value = $value->year . '-' . $value->month . '-' . $value->date; |
2380 | 2380 | } |
@@ -2382,9 +2382,9 @@ discard block |
||
2382 | 2382 | $value = call_user_func_array($this->arrayObjectConversionMethod, [$value]); |
2383 | 2383 | } |
2384 | 2384 | |
2385 | - $this->builderCache->binds[ $key ] = $value; |
|
2386 | - $this->builderCache->sets[ $this->conn->protectIdentifiers($key, false, |
|
2387 | - $escape) ] = ':' . $key; |
|
2385 | + $this->builderCache->binds[$key] = $value; |
|
2386 | + $this->builderCache->sets[$this->conn->protectIdentifiers($key, false, |
|
2387 | + $escape)] = ':' . $key; |
|
2388 | 2388 | } |
2389 | 2389 | |
2390 | 2390 | return $this; |
@@ -2411,7 +2411,7 @@ discard block |
||
2411 | 2411 | foreach (get_object_vars($object) as $key => $value) { |
2412 | 2412 | // There are some built in keys we need to ignore for this conversion |
2413 | 2413 | if ( ! is_object($value) && ! is_array($value) && $key !== '_parent_name') { |
2414 | - $array[ $key ] = $value; |
|
2414 | + $array[$key] = $value; |
|
2415 | 2415 | } |
2416 | 2416 | } |
2417 | 2417 | |
@@ -2459,7 +2459,7 @@ discard block |
||
2459 | 2459 | $affectedRows = 0; |
2460 | 2460 | for ($i = 0, $total = count($sets); $i < $total; $i += $batchSize) { |
2461 | 2461 | $Sql = $this->platformInsertBatchStatement( |
2462 | - $this->conn->protectIdentifiers($this->builderCache->from[ 0 ], true, $escape, false), |
|
2462 | + $this->conn->protectIdentifiers($this->builderCache->from[0], true, $escape, false), |
|
2463 | 2463 | $this->builderCache->keys, |
2464 | 2464 | array_slice($this->builderCache->sets, $i, $batchSize) |
2465 | 2465 | ); |
@@ -2560,8 +2560,8 @@ discard block |
||
2560 | 2560 | // There are some built in keys we need to ignore for this conversion |
2561 | 2561 | if ($field !== '_parent_name') { |
2562 | 2562 | $i = 0; |
2563 | - foreach ($out[ $field ] as $data) { |
|
2564 | - $array[ $i++ ][ $field ] = $data; |
|
2563 | + foreach ($out[$field] as $data) { |
|
2564 | + $array[$i++][$field] = $data; |
|
2565 | 2565 | } |
2566 | 2566 | } |
2567 | 2567 | } |
@@ -2612,7 +2612,7 @@ discard block |
||
2612 | 2612 | if (count($this->builderCache->sets)) { |
2613 | 2613 | $sqlStatement = $this->platformReplaceStatement( |
2614 | 2614 | $this->conn->protectIdentifiers( |
2615 | - $this->builderCache->from[ 0 ], |
|
2615 | + $this->builderCache->from[0], |
|
2616 | 2616 | true, |
2617 | 2617 | $escape, |
2618 | 2618 | false |
@@ -2675,7 +2675,7 @@ discard block |
||
2675 | 2675 | $affectedRows = 0; |
2676 | 2676 | for ($i = 0, $total = count($sets); $i < $total; $i += $batchSize) { |
2677 | 2677 | $Sql = $this->platformReplaceStatement( |
2678 | - $this->conn->protectIdentifiers($this->builderCache->from[ 0 ], true, $escape, false), |
|
2678 | + $this->conn->protectIdentifiers($this->builderCache->from[0], true, $escape, false), |
|
2679 | 2679 | $this->builderCache->keys, |
2680 | 2680 | array_slice($this->builderCache->sets, $i, $batchSize) |
2681 | 2681 | ); |
@@ -2727,7 +2727,7 @@ discard block |
||
2727 | 2727 | if (count($this->builderCache->sets) && count($this->builderCache->from)) { |
2728 | 2728 | $sqlStatement = $this->platformUpdateStatement( |
2729 | 2729 | $this->conn->protectIdentifiers( |
2730 | - $this->builderCache->from[ 0 ], |
|
2730 | + $this->builderCache->from[0], |
|
2731 | 2731 | true, |
2732 | 2732 | $escape, |
2733 | 2733 | false |
@@ -2788,7 +2788,7 @@ discard block |
||
2788 | 2788 | $affectedRows = 0; |
2789 | 2789 | for ($i = 0, $total = count($this->builderCache->sets); $i < $total; $i += $batchSize) { |
2790 | 2790 | $sql = $this->platformUpdateBatchStatement( |
2791 | - $this->builderCache->from[ 0 ], |
|
2791 | + $this->builderCache->from[0], |
|
2792 | 2792 | array_slice($this->builderCache->sets, $i, $batchSize), |
2793 | 2793 | $this->conn->protectIdentifiers($index, false, $escape, false) |
2794 | 2794 | ); |
@@ -2800,7 +2800,7 @@ discard block |
||
2800 | 2800 | $affectedRows += $this->conn->getAffectedRows(); |
2801 | 2801 | } |
2802 | 2802 | |
2803 | - $this->builderCache[ 'where' ] = []; |
|
2803 | + $this->builderCache['where'] = []; |
|
2804 | 2804 | } |
2805 | 2805 | |
2806 | 2806 | if ( ! $this->testMode) { |
@@ -2844,7 +2844,7 @@ discard block |
||
2844 | 2844 | |
2845 | 2845 | $bind = $this->bind($key, $value); |
2846 | 2846 | |
2847 | - $row[ $this->conn->protectIdentifiers($key, false, $escape) ] = ':' . $bind; |
|
2847 | + $row[$this->conn->protectIdentifiers($key, false, $escape)] = ':' . $bind; |
|
2848 | 2848 | } |
2849 | 2849 | |
2850 | 2850 | if ($indexSet === false) { |
@@ -2895,7 +2895,7 @@ discard block |
||
2895 | 2895 | |
2896 | 2896 | $sqlStatement = $this->platformDeleteStatement( |
2897 | 2897 | $this->conn->protectIdentifiers( |
2898 | - $this->builderCache->from[ 0 ], |
|
2898 | + $this->builderCache->from[0], |
|
2899 | 2899 | true, |
2900 | 2900 | $this->conn->isProtectIdentifiers, |
2901 | 2901 | false |
@@ -3074,10 +3074,10 @@ discard block |
||
3074 | 3074 | // The reason we protect identifiers here rather than in the select() function |
3075 | 3075 | // is because until the user calls the from() function we don't know if there are aliases |
3076 | 3076 | foreach ($this->builderCache->select as $selectKey => $selectField) { |
3077 | - $noEscape = isset($this->builderCache->noEscape [ $selectKey ]) |
|
3078 | - ? $this->builderCache->noEscape [ $selectKey ] |
|
3077 | + $noEscape = isset($this->builderCache->noEscape [$selectKey]) |
|
3078 | + ? $this->builderCache->noEscape [$selectKey] |
|
3079 | 3079 | : null; |
3080 | - $this->builderCache->select [ $selectKey ] = $this->conn->protectIdentifiers( |
|
3080 | + $this->builderCache->select [$selectKey] = $this->conn->protectIdentifiers( |
|
3081 | 3081 | $selectField, |
3082 | 3082 | false, |
3083 | 3083 | $noEscape |
@@ -3196,28 +3196,28 @@ discard block |
||
3196 | 3196 | if (count($this->builderCache->{$cacheKey}) > 0) { |
3197 | 3197 | for ($i = 0, $c = count($this->builderCache->{$cacheKey}); $i < $c; $i++) { |
3198 | 3198 | // Is this condition already compiled? |
3199 | - if (is_string($this->builderCache->{$cacheKey}[ $i ])) { |
|
3199 | + if (is_string($this->builderCache->{$cacheKey}[$i])) { |
|
3200 | 3200 | continue; |
3201 | - } elseif ($this->builderCache->{$cacheKey}[ $i ][ 'escape' ] === false) { |
|
3202 | - $this->builderCache->{$cacheKey}[ $i ] |
|
3203 | - = $this->builderCache->{$cacheKey}[ $i ][ 'condition' ]; |
|
3201 | + } elseif ($this->builderCache->{$cacheKey}[$i]['escape'] === false) { |
|
3202 | + $this->builderCache->{$cacheKey}[$i] |
|
3203 | + = $this->builderCache->{$cacheKey}[$i]['condition']; |
|
3204 | 3204 | continue; |
3205 | 3205 | } |
3206 | 3206 | |
3207 | 3207 | // Split multiple conditions |
3208 | 3208 | $conditions = preg_split( |
3209 | 3209 | '/((?:^|\s+)AND\s+|(?:^|\s+)OR\s+)/i', |
3210 | - $this->builderCache->{$cacheKey}[ $i ][ 'condition' ], |
|
3210 | + $this->builderCache->{$cacheKey}[$i]['condition'], |
|
3211 | 3211 | -1, |
3212 | 3212 | PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY |
3213 | 3213 | ); |
3214 | 3214 | |
3215 | 3215 | for ($ci = 0, $cc = count($conditions); $ci < $cc; $ci++) { |
3216 | - if (($op = $this->getOperator($conditions[ $ci ])) === false |
|
3216 | + if (($op = $this->getOperator($conditions[$ci])) === false |
|
3217 | 3217 | OR |
3218 | 3218 | ! preg_match( |
3219 | 3219 | '/^(\(?)(.*)(' . preg_quote($op, '/') . ')\s*(.*(?<!\)))?(\)?)$/i', |
3220 | - $conditions[ $ci ], |
|
3220 | + $conditions[$ci], |
|
3221 | 3221 | $matches |
3222 | 3222 | ) |
3223 | 3223 | ) { |
@@ -3233,16 +3233,16 @@ discard block |
||
3233 | 3233 | // 5 => ')' /* optional */ |
3234 | 3234 | // ); |
3235 | 3235 | |
3236 | - if ( ! empty($matches[ 4 ])) { |
|
3236 | + if ( ! empty($matches[4])) { |
|
3237 | 3237 | //$this->isLiteral($matches[4]) OR $matches[4] = $this->protectIdentifiers(trim($matches[4])); |
3238 | - $matches[ 4 ] = ' ' . $matches[ 4 ]; |
|
3238 | + $matches[4] = ' ' . $matches[4]; |
|
3239 | 3239 | } |
3240 | 3240 | |
3241 | - $conditions[ $ci ] = $matches[ 1 ] . $this->conn->protectIdentifiers(trim($matches[ 2 ])) |
|
3242 | - . ' ' . trim($matches[ 3 ]) . $matches[ 4 ] . $matches[ 5 ]; |
|
3241 | + $conditions[$ci] = $matches[1] . $this->conn->protectIdentifiers(trim($matches[2])) |
|
3242 | + . ' ' . trim($matches[3]) . $matches[4] . $matches[5]; |
|
3243 | 3243 | } |
3244 | 3244 | |
3245 | - $this->builderCache->{$cacheKey}[ $i ] = implode('', $conditions); |
|
3245 | + $this->builderCache->{$cacheKey}[$i] = implode('', $conditions); |
|
3246 | 3246 | } |
3247 | 3247 | |
3248 | 3248 | if ($cacheKey === 'having') { |
@@ -3281,17 +3281,17 @@ discard block |
||
3281 | 3281 | if (count($this->builderCache->groupBy) > 0) { |
3282 | 3282 | for ($i = 0, $c = count($this->builderCache->groupBy); $i < $c; $i++) { |
3283 | 3283 | // Is it already compiled? |
3284 | - if (is_string($this->builderCache->groupBy[ $i ])) { |
|
3284 | + if (is_string($this->builderCache->groupBy[$i])) { |
|
3285 | 3285 | continue; |
3286 | 3286 | } |
3287 | 3287 | |
3288 | - $this->builderCache->groupBy[ $i ] = ($this->builderCache->groupBy[ $i ][ 'escape' ] |
|
3288 | + $this->builderCache->groupBy[$i] = ($this->builderCache->groupBy[$i]['escape'] |
|
3289 | 3289 | === false OR |
3290 | 3290 | $this->isLiteral( |
3291 | - $this->builderCache->groupBy[ $i ][ 'field' ] |
|
3291 | + $this->builderCache->groupBy[$i]['field'] |
|
3292 | 3292 | )) |
3293 | - ? $this->builderCache->groupBy[ $i ][ 'field' ] |
|
3294 | - : $this->conn->protectIdentifiers($this->builderCache->groupBy[ $i ][ 'field' ]); |
|
3293 | + ? $this->builderCache->groupBy[$i]['field'] |
|
3294 | + : $this->conn->protectIdentifiers($this->builderCache->groupBy[$i]['field']); |
|
3295 | 3295 | } |
3296 | 3296 | |
3297 | 3297 | return "\n" . sprintf( |
@@ -3336,7 +3336,7 @@ discard block |
||
3336 | 3336 | : ["'"]; |
3337 | 3337 | } |
3338 | 3338 | |
3339 | - return in_array($string[ 0 ], $stringArray, true); |
|
3339 | + return in_array($string[0], $stringArray, true); |
|
3340 | 3340 | } |
3341 | 3341 | |
3342 | 3342 | //-------------------------------------------------------------------- |
@@ -3394,18 +3394,18 @@ discard block |
||
3394 | 3394 | { |
3395 | 3395 | if (is_array($this->builderCache->orderBy) && count($this->builderCache->orderBy) > 0) { |
3396 | 3396 | for ($i = 0, $c = count($this->builderCache->orderBy); $i < $c; $i++) { |
3397 | - if ($this->builderCache->orderBy[ $i ][ 'escape' ] !== false |
|
3397 | + if ($this->builderCache->orderBy[$i]['escape'] !== false |
|
3398 | 3398 | && ! $this->isLiteral( |
3399 | - $this->builderCache->orderBy[ $i ][ 'field' ] |
|
3399 | + $this->builderCache->orderBy[$i]['field'] |
|
3400 | 3400 | ) |
3401 | 3401 | ) { |
3402 | - $this->builderCache->orderBy[ $i ][ 'field' ] = $this->conn->protectIdentifiers( |
|
3403 | - $this->builderCache->orderBy[ $i ][ 'field' ] |
|
3402 | + $this->builderCache->orderBy[$i]['field'] = $this->conn->protectIdentifiers( |
|
3403 | + $this->builderCache->orderBy[$i]['field'] |
|
3404 | 3404 | ); |
3405 | 3405 | } |
3406 | 3406 | |
3407 | - $this->builderCache->orderBy[ $i ] = $this->builderCache->orderBy[ $i ][ 'field' ] |
|
3408 | - . $this->builderCache->orderBy[ $i ][ 'direction' ]; |
|
3407 | + $this->builderCache->orderBy[$i] = $this->builderCache->orderBy[$i]['field'] |
|
3408 | + . $this->builderCache->orderBy[$i]['direction']; |
|
3409 | 3409 | } |
3410 | 3410 | |
3411 | 3411 | return $this->builderCache->orderBy = "\n" . sprintf( |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | */ |
81 | 81 | public function &__get($property) |
82 | 82 | { |
83 | - return $this->vars[ $property ]; |
|
83 | + return $this->vars[$property]; |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | // ------------------------------------------------------------------------ |
@@ -96,16 +96,16 @@ discard block |
||
96 | 96 | public function store($index, $value) |
97 | 97 | { |
98 | 98 | if (array_key_exists($index, $this->vars)) { |
99 | - if (is_array($this->vars[ $index ])) { |
|
99 | + if (is_array($this->vars[$index])) { |
|
100 | 100 | if (is_array($value)) { |
101 | - $this->vars[ $index ] = array_merge($this->vars[ $index ], $value); |
|
101 | + $this->vars[$index] = array_merge($this->vars[$index], $value); |
|
102 | 102 | } else { |
103 | - array_push($this->vars[ $index ], $value); |
|
103 | + array_push($this->vars[$index], $value); |
|
104 | 104 | } |
105 | - } elseif (is_bool($this->vars[ $index ])) { |
|
106 | - $this->vars[ $index ] = (bool)$value; |
|
105 | + } elseif (is_bool($this->vars[$index])) { |
|
106 | + $this->vars[$index] = (bool)$value; |
|
107 | 107 | } else { |
108 | - $this->vars[ $index ] = $value; |
|
108 | + $this->vars[$index] = $value; |
|
109 | 109 | } |
110 | 110 | } |
111 | 111 | |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | protected function resetRun(array $cacheKeys) |
214 | 214 | { |
215 | 215 | foreach ($cacheKeys as $cacheKey => $cacheDefaultValue) { |
216 | - $this->vars[ $cacheKey ] = $cacheDefaultValue; |
|
216 | + $this->vars[$cacheKey] = $cacheDefaultValue; |
|
217 | 217 | } |
218 | 218 | } |
219 | 219 |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | */ |
183 | 183 | public function addFilter($field, $value) |
184 | 184 | { |
185 | - $this->filter[ $field ] = $value; |
|
185 | + $this->filter[$field] = $value; |
|
186 | 186 | |
187 | 187 | return $this; |
188 | 188 | } |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | */ |
234 | 234 | public function addOption($option, $value) |
235 | 235 | { |
236 | - $this->options[ $option ] = $value; |
|
236 | + $this->options[$option] = $value; |
|
237 | 237 | |
238 | 238 | return $this; |
239 | 239 | } |
@@ -203,7 +203,7 @@ |
||
203 | 203 | */ |
204 | 204 | public function setError($errorCode, $errorMessage) |
205 | 205 | { |
206 | - $this->error[ $errorCode ] = $errorMessage; |
|
206 | + $this->error[$errorCode] = $errorMessage; |
|
207 | 207 | |
208 | 208 | return $this; |
209 | 209 | } |