@@ -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 | // ------------------------------------------------------------------------ |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | if ( ! preg_match('/^([adObis]):/', $string, $matches)) {
|
| 215 | 215 | return false; |
| 216 | 216 | } |
| 217 | - switch ($matches[ 1 ]) {
|
|
| 217 | + switch ($matches[1]) {
|
|
| 218 | 218 | case 'a' : |
| 219 | 219 | case 'O' : |
| 220 | 220 | case 's' : |
@@ -249,11 +249,11 @@ discard block |
||
| 249 | 249 | |
| 250 | 250 | foreach ($fields as $fieldName => $fieldValue) {
|
| 251 | 251 | if ($this->isJSON($fieldValue)) {
|
| 252 | - $fields[ $fieldName ] = new Columns\DataJSON(json_decode($fieldValue, true)); |
|
| 252 | + $fields[$fieldName] = new Columns\DataJSON(json_decode($fieldValue, true)); |
|
| 253 | 253 | } elseif ($this->isSerialized($fieldValue)) {
|
| 254 | - $fields[ $fieldName ] = new Columns\DataSerialize(unserialize($fieldValue)); |
|
| 254 | + $fields[$fieldName] = new Columns\DataSerialize(unserialize($fieldValue)); |
|
| 255 | 255 | } else {
|
| 256 | - $fields[ $fieldName ] = $fieldValue; |
|
| 256 | + $fields[$fieldName] = $fieldValue; |
|
| 257 | 257 | } |
| 258 | 258 | } |
| 259 | 259 | |
@@ -323,9 +323,9 @@ discard block |
||
| 323 | 323 | */ |
| 324 | 324 | public function offsetGet($offset) |
| 325 | 325 | {
|
| 326 | - if (isset($this->columns[ $offset ])) {
|
|
| 326 | + if (isset($this->columns[$offset])) {
|
|
| 327 | 327 | |
| 328 | - $data = $this->columns[ $offset ]; |
|
| 328 | + $data = $this->columns[$offset]; |
|
| 329 | 329 | |
| 330 | 330 | if ($this->isJSON($data)) {
|
| 331 | 331 | return new Columns\DataJSON(json_decode($data, true)); |
@@ -360,7 +360,7 @@ discard block |
||
| 360 | 360 | */ |
| 361 | 361 | public function offsetSet($offset, $value) |
| 362 | 362 | {
|
| 363 | - $this->columns[ $offset ] = $value; |
|
| 363 | + $this->columns[$offset] = $value; |
|
| 364 | 364 | } |
| 365 | 365 | |
| 366 | 366 | // ------------------------------------------------------------------------ |
@@ -401,7 +401,7 @@ discard block |
||
| 401 | 401 | */ |
| 402 | 402 | public function offsetExists($offset) |
| 403 | 403 | {
|
| 404 | - return isset($this->columns[ $offset ]); |
|
| 404 | + return isset($this->columns[$offset]); |
|
| 405 | 405 | } |
| 406 | 406 | |
| 407 | 407 | // ------------------------------------------------------------------------ |
@@ -422,7 +422,7 @@ discard block |
||
| 422 | 422 | */ |
| 423 | 423 | public function offsetUnset($field) |
| 424 | 424 | {
|
| 425 | - unset($this->columns[ $field ]); |
|
| 425 | + unset($this->columns[$field]); |
|
| 426 | 426 | } |
| 427 | 427 | |
| 428 | 428 | // ------------------------------------------------------------------------ |
@@ -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 | |
@@ -42,8 +42,8 @@ |
||
| 42 | 42 | 'pages' => 0, |
| 43 | 43 | ], $total)); |
| 44 | 44 | |
| 45 | - if (isset($total[ 'limit' ])) {
|
|
| 46 | - $this->limit = $total[ 'limit' ]; |
|
| 45 | + if (isset($total['limit'])) {
|
|
| 46 | + $this->limit = $total['limit']; |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | $this->setLimit($this->limit); |
@@ -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 | } |