@@ -16,7 +16,7 @@ |
||
16 | 16 | * @param $className |
17 | 17 | */ |
18 | 18 | spl_autoload_register( |
19 | - function ($className) { |
|
19 | + function($className) { |
|
20 | 20 | if (strpos($className, 'O2System\Database\\') === false) { |
21 | 21 | return; |
22 | 22 | } |
@@ -228,9 +228,9 @@ discard block |
||
228 | 228 | // No connection resource? Check if there is a failover else throw an error |
229 | 229 | if ( ! $this->handle) { |
230 | 230 | // Check if there is a failover set |
231 | - if ( ! empty($this->config[ 'failover' ]) && is_array($this->config[ 'failover' ])) { |
|
231 | + if ( ! empty($this->config['failover']) && is_array($this->config['failover'])) { |
|
232 | 232 | // Go over all the failovers |
233 | - foreach ($this->config[ 'failover' ] as $failover) { |
|
233 | + foreach ($this->config['failover'] as $failover) { |
|
234 | 234 | |
235 | 235 | // Try to connect |
236 | 236 | $this->platformConnectHandler($failover = new Config($failover)); |
@@ -301,11 +301,11 @@ discard block |
||
301 | 301 | */ |
302 | 302 | public function getPlatformInfo() |
303 | 303 | { |
304 | - if (isset($this->queriesResultCache[ 'platformInfo' ])) { |
|
305 | - return $this->queriesResultCache[ 'platformInfo' ]; |
|
304 | + if (isset($this->queriesResultCache['platformInfo'])) { |
|
305 | + return $this->queriesResultCache['platformInfo']; |
|
306 | 306 | } |
307 | 307 | |
308 | - return $this->queriesResultCache[ 'platformInfo' ] = $this->platformGetPlatformInfoHandler(); |
|
308 | + return $this->queriesResultCache['platformInfo'] = $this->platformGetPlatformInfoHandler(); |
|
309 | 309 | } |
310 | 310 | |
311 | 311 | // ------------------------------------------------------------------------ |
@@ -473,11 +473,11 @@ discard block |
||
473 | 473 | */ |
474 | 474 | final public function hasDatabase($databaseName) |
475 | 475 | { |
476 | - if (empty($this->queriesResultCache[ 'databaseNames' ])) { |
|
476 | + if (empty($this->queriesResultCache['databaseNames'])) { |
|
477 | 477 | $this->getDatabases(); |
478 | 478 | } |
479 | 479 | |
480 | - return (bool)in_array($databaseName, $this->queriesResultCache[ 'databaseNames' ]); |
|
480 | + return (bool)in_array($databaseName, $this->queriesResultCache['databaseNames']); |
|
481 | 481 | } |
482 | 482 | |
483 | 483 | //-------------------------------------------------------------------- |
@@ -505,11 +505,11 @@ discard block |
||
505 | 505 | */ |
506 | 506 | public function hasCollection($collection) |
507 | 507 | { |
508 | - if (empty($this->queriesResultCache[ 'collectionNames' ])) { |
|
508 | + if (empty($this->queriesResultCache['collectionNames'])) { |
|
509 | 509 | $this->getCollections(); |
510 | 510 | } |
511 | 511 | |
512 | - return (bool)in_array($collection, $this->queriesResultCache[ 'collectionNames' ]); |
|
512 | + return (bool)in_array($collection, $this->queriesResultCache['collectionNames']); |
|
513 | 513 | } |
514 | 514 | |
515 | 515 | // ------------------------------------------------------------------------ |
@@ -537,11 +537,11 @@ discard block |
||
537 | 537 | */ |
538 | 538 | public function hasKey($key, $collection) |
539 | 539 | { |
540 | - if (empty($this->queriesResultCache[ 'collectionKeys' ][ $collection ])) { |
|
540 | + if (empty($this->queriesResultCache['collectionKeys'][$collection])) { |
|
541 | 541 | $this->getKeys($collection); |
542 | 542 | } |
543 | 543 | |
544 | - return (bool)in_array($key, $this->queriesResultCache[ 'collectionKeys' ][ $collection ]); |
|
544 | + return (bool)in_array($key, $this->queriesResultCache['collectionKeys'][$collection]); |
|
545 | 545 | } |
546 | 546 | |
547 | 547 | // ------------------------------------------------------------------------ |
@@ -572,11 +572,11 @@ discard block |
||
572 | 572 | */ |
573 | 573 | public function hasIndex($index, $collection) |
574 | 574 | { |
575 | - if (empty($this->queriesResultCache[ 'collectionIndexes' ][ $collection ])) { |
|
575 | + if (empty($this->queriesResultCache['collectionIndexes'][$collection])) { |
|
576 | 576 | $this->getIndexes($collection); |
577 | 577 | } |
578 | 578 | |
579 | - return (bool)in_array($index, $this->queriesResultCache[ 'collectionIndexes' ][ $collection ]); |
|
579 | + return (bool)in_array($index, $this->queriesResultCache['collectionIndexes'][$collection]); |
|
580 | 580 | } |
581 | 581 | |
582 | 582 | // ------------------------------------------------------------------------ |
@@ -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 | } |
@@ -48,14 +48,14 @@ discard block |
||
48 | 48 | |
49 | 49 | public function &loadConnection($connectionOffset) |
50 | 50 | { |
51 | - $loadConnection[ $connectionOffset ] = false; |
|
51 | + $loadConnection[$connectionOffset] = false; |
|
52 | 52 | |
53 | 53 | if ( ! $this->exists($connectionOffset) and $this->config->offsetExists($connectionOffset)) { |
54 | 54 | |
55 | 55 | $connectionConfig = $this->config->offsetGet($connectionOffset); |
56 | 56 | |
57 | 57 | if (is_array($connectionConfig)) { |
58 | - new DataStructures\Config($this->config[ $connectionOffset ]); |
|
58 | + new DataStructures\Config($this->config[$connectionOffset]); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | $this->createConnection($connectionOffset, $connectionConfig); |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | ]; |
91 | 91 | |
92 | 92 | if (array_key_exists($connectionConfig->driver, $driverMaps)) { |
93 | - if (class_exists($driverClassName = $driverMaps[ $connectionConfig->driver ])) { |
|
93 | + if (class_exists($driverClassName = $driverMaps[$connectionConfig->driver])) { |
|
94 | 94 | $driverInstance = new $driverClassName($connectionConfig); |
95 | 95 | $this->register($driverInstance, $connectionOffset); |
96 | 96 | } |
@@ -29,9 +29,9 @@ |
||
29 | 29 | */ |
30 | 30 | public function __construct(array $config) |
31 | 31 | { |
32 | - if (isset($config[ 'default' ])) { |
|
32 | + if (isset($config['default'])) { |
|
33 | 33 | foreach ($config as $poolOffset => $poolConfig) { |
34 | - $config[ $poolOffset ] = new self($poolConfig); |
|
34 | + $config[$poolOffset] = new self($poolConfig); |
|
35 | 35 | } |
36 | 36 | } |
37 | 37 |
@@ -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 | } |
@@ -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 | } |