@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | |
| 119 | 119 | if ($field === '_id') {
|
| 120 | 120 | foreach ($values as $key => $value) {
|
| 121 | - $values[ $key ] = new \MongoDb\BSON\ObjectID($value); |
|
| 121 | + $values[$key] = new \MongoDb\BSON\ObjectID($value); |
|
| 122 | 122 | } |
| 123 | 123 | } |
| 124 | 124 | |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | $builderCache->store('from', $collection);
|
| 189 | 189 | $builderCache->store('where', ['_id' => $document->_id]);
|
| 190 | 190 | $document = $document->getArrayCopy(); |
| 191 | - unset($document[ '_id' ]); |
|
| 191 | + unset($document['_id']); |
|
| 192 | 192 | |
| 193 | 193 | $builderCache->store('sets', array_merge($document, $sets));
|
| 194 | 194 | |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | $document = $this->get()->first(); |
| 230 | 230 | $documentIds[] = $document->_id; |
| 231 | 231 | $document = $document->getArrayCopy(); |
| 232 | - unset($document[ '_id' ]); |
|
| 232 | + unset($document['_id']); |
|
| 233 | 233 | |
| 234 | 234 | $documents[] = array_merge($document, $sets); |
| 235 | 235 | } |
@@ -100,17 +100,17 @@ discard block |
||
| 100 | 100 | $cursor->setTypeMap(['root' => 'array', 'document' => 'array']); |
| 101 | 101 | $result = current($cursor->toArray()); |
| 102 | 102 | |
| 103 | - $this->queriesResultCache[ 'databaseNames' ] = []; |
|
| 103 | + $this->queriesResultCache['databaseNames'] = []; |
|
| 104 | 104 | |
| 105 | - if ( ! empty($result[ 'databases' ])) {
|
|
| 106 | - foreach ($result[ 'databases' ] as $database) {
|
|
| 107 | - if ( ! in_array($database[ 'name' ], ['admin', 'local'])) {
|
|
| 108 | - $this->queriesResultCache[ 'databaseNames' ][] = $database[ 'name' ]; |
|
| 105 | + if ( ! empty($result['databases'])) {
|
|
| 106 | + foreach ($result['databases'] as $database) {
|
|
| 107 | + if ( ! in_array($database['name'], ['admin', 'local'])) {
|
|
| 108 | + $this->queriesResultCache['databaseNames'][] = $database['name']; |
|
| 109 | 109 | } |
| 110 | 110 | } |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - return $this->queriesResultCache[ 'databaseNames' ]; |
|
| 113 | + return $this->queriesResultCache['databaseNames']; |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | // ------------------------------------------------------------------------ |
@@ -130,15 +130,15 @@ discard block |
||
| 130 | 130 | |
| 131 | 131 | $result = new \IteratorIterator($cursor); |
| 132 | 132 | |
| 133 | - $this->queriesResultCache[ 'collectionNames' ] = []; |
|
| 133 | + $this->queriesResultCache['collectionNames'] = []; |
|
| 134 | 134 | |
| 135 | 135 | foreach ($result as $collection) {
|
| 136 | - if ($collection[ 'type' ] === 'collection') {
|
|
| 137 | - $this->queriesResultCache[ 'collectionNames' ][] = $collection[ 'name' ]; |
|
| 136 | + if ($collection['type'] === 'collection') {
|
|
| 137 | + $this->queriesResultCache['collectionNames'][] = $collection['name']; |
|
| 138 | 138 | } |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - return $this->queriesResultCache[ 'collectionNames' ]; |
|
| 141 | + return $this->queriesResultCache['collectionNames']; |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | // ------------------------------------------------------------------------ |
@@ -158,13 +158,13 @@ discard block |
||
| 158 | 158 | |
| 159 | 159 | $result = current($cursor->toArray()); |
| 160 | 160 | |
| 161 | - $this->queriesResultCache[ 'collectionKeys' ][ $collection ] = []; |
|
| 161 | + $this->queriesResultCache['collectionKeys'][$collection] = []; |
|
| 162 | 162 | |
| 163 | 163 | foreach (get_object_vars($result) as $key => $value) {
|
| 164 | - $this->queriesResultCache[ 'collectionKeys' ][ $collection ][] = $key; |
|
| 164 | + $this->queriesResultCache['collectionKeys'][$collection][] = $key; |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - return $this->queriesResultCache[ 'collectionKeys' ][ $collection ]; |
|
| 167 | + return $this->queriesResultCache['collectionKeys'][$collection]; |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | // ------------------------------------------------------------------------ |
@@ -185,13 +185,13 @@ discard block |
||
| 185 | 185 | |
| 186 | 186 | $result = new \IteratorIterator($cursor); |
| 187 | 187 | |
| 188 | - $this->queriesResultCache[ 'collectionIndexes' ][ $collection ] = []; |
|
| 188 | + $this->queriesResultCache['collectionIndexes'][$collection] = []; |
|
| 189 | 189 | |
| 190 | 190 | foreach ($result as $index) {
|
| 191 | - $this->queriesResultCache[ 'collectionIndexes' ][ $collection ][] = $index[ 'name' ]; |
|
| 191 | + $this->queriesResultCache['collectionIndexes'][$collection][] = $index['name']; |
|
| 192 | 192 | } |
| 193 | 193 | |
| 194 | - return $this->queriesResultCache[ 'collectionIndexes' ][ $collection ]; |
|
| 194 | + return $this->queriesResultCache['collectionIndexes'][$collection]; |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | // ------------------------------------------------------------------------ |
@@ -234,9 +234,9 @@ discard block |
||
| 234 | 234 | protected function platformGetPlatformInfoHandler() |
| 235 | 235 | {
|
| 236 | 236 | $metadata = $this->server->getInfo(); |
| 237 | - $metadata[ 'latency' ] = $this->server->getLatency(); |
|
| 238 | - $metadata[ 'type' ] = $this->server->getType(); |
|
| 239 | - $metadata[ 'tags' ] = $this->server->getTags(); |
|
| 237 | + $metadata['latency'] = $this->server->getLatency(); |
|
| 238 | + $metadata['type'] = $this->server->getType(); |
|
| 239 | + $metadata['tags'] = $this->server->getTags(); |
|
| 240 | 240 | |
| 241 | 241 | return new SplArrayObject([ |
| 242 | 242 | 'name' => $this->getPlatform(), |
@@ -297,10 +297,10 @@ discard block |
||
| 297 | 297 | {
|
| 298 | 298 | $this->parseQueryStatement($statement); |
| 299 | 299 | |
| 300 | - if (isset($options[ 'method' ])) {
|
|
| 300 | + if (isset($options['method'])) {
|
|
| 301 | 301 | |
| 302 | - $method = $options[ 'method' ]; |
|
| 303 | - unset($options[ 'method' ]); |
|
| 302 | + $method = $options['method']; |
|
| 303 | + unset($options['method']); |
|
| 304 | 304 | |
| 305 | 305 | $options = array_merge(['safe' => true, 'ordered' => true], $options); |
| 306 | 306 | $bulk = new \MongoDb\Driver\BulkWrite($options); |
@@ -384,7 +384,7 @@ discard block |
||
| 384 | 384 | $projection = []; |
| 385 | 385 | |
| 386 | 386 | foreach ($builderCache->select as $field) {
|
| 387 | - $projection[ $field ] = 1; |
|
| 387 | + $projection[$field] = 1; |
|
| 388 | 388 | } |
| 389 | 389 | |
| 390 | 390 | $statement->addOption('projection', $projection);
|
@@ -394,9 +394,9 @@ discard block |
||
| 394 | 394 | if (count($builderCache->whereIn)) {
|
| 395 | 395 | foreach ($builderCache->whereIn as $field => $clause) {
|
| 396 | 396 | if (count($builderCache->orWhereIn)) {
|
| 397 | - $builderCache->orWhere[ $field ] = ['$in' => $clause]; |
|
| 397 | + $builderCache->orWhere[$field] = ['$in' => $clause]; |
|
| 398 | 398 | } else {
|
| 399 | - $builderCache->where[ $field ] = ['$in' => $clause]; |
|
| 399 | + $builderCache->where[$field] = ['$in' => $clause]; |
|
| 400 | 400 | } |
| 401 | 401 | } |
| 402 | 402 | } |
@@ -404,44 +404,44 @@ discard block |
||
| 404 | 404 | // Filter Where Not In |
| 405 | 405 | if (count($builderCache->whereNotIn)) {
|
| 406 | 406 | foreach ($builderCache->whereNotIn as $field => $clause) {
|
| 407 | - $builderCache->where[ $field ] = ['$nin' => $clause]; |
|
| 407 | + $builderCache->where[$field] = ['$nin' => $clause]; |
|
| 408 | 408 | } |
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | // Filter Or Where In |
| 412 | 412 | if (count($builderCache->orWhereIn)) {
|
| 413 | 413 | foreach ($builderCache->orWhereIn as $field => $clause) {
|
| 414 | - $builderCache->orWhere[ $field ] = ['$in' => $clause]; |
|
| 414 | + $builderCache->orWhere[$field] = ['$in' => $clause]; |
|
| 415 | 415 | } |
| 416 | 416 | } |
| 417 | 417 | |
| 418 | 418 | // Filter Or Where Not In |
| 419 | 419 | if (count($builderCache->orWhereNotIn)) {
|
| 420 | 420 | foreach ($builderCache->orWhereNotIn as $field => $clause) {
|
| 421 | - $builderCache->orWhere[ $field ] = ['$nin' => $clause]; |
|
| 421 | + $builderCache->orWhere[$field] = ['$nin' => $clause]; |
|
| 422 | 422 | } |
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | // Filter Where Between |
| 426 | 426 | if (count($builderCache->between)) {
|
| 427 | 427 | foreach ($builderCache->between as $field => $clause) {
|
| 428 | - $builderCache->where[ $field ] = ['$gte' => $clause[ 'start' ], '$lte' => $clause[ 'end' ]]; |
|
| 428 | + $builderCache->where[$field] = ['$gte' => $clause['start'], '$lte' => $clause['end']]; |
|
| 429 | 429 | } |
| 430 | 430 | } |
| 431 | 431 | |
| 432 | 432 | // Filter Or Where Between |
| 433 | 433 | if (count($builderCache->orBetween)) {
|
| 434 | 434 | foreach ($builderCache->orBetween as $field => $clause) {
|
| 435 | - $builderCache->orWhere[ $field ] = ['$gte' => $clause[ 'start' ], '$lte' => $clause[ 'end' ]]; |
|
| 435 | + $builderCache->orWhere[$field] = ['$gte' => $clause['start'], '$lte' => $clause['end']]; |
|
| 436 | 436 | } |
| 437 | 437 | } |
| 438 | 438 | |
| 439 | 439 | // Filter Where Not Between |
| 440 | 440 | if (count($builderCache->notBetween)) {
|
| 441 | 441 | foreach ($builderCache->notBetween as $field => $clause) {
|
| 442 | - $builderCache->where[ $field ][ '$not' ] = [ |
|
| 443 | - '$gte' => $clause[ 'start' ], |
|
| 444 | - '$lte' => $clause[ 'end' ], |
|
| 442 | + $builderCache->where[$field]['$not'] = [ |
|
| 443 | + '$gte' => $clause['start'], |
|
| 444 | + '$lte' => $clause['end'], |
|
| 445 | 445 | ]; |
| 446 | 446 | } |
| 447 | 447 | } |
@@ -449,9 +449,9 @@ discard block |
||
| 449 | 449 | // Filter Or Where Not Between |
| 450 | 450 | if (count($builderCache->orNotBetween)) {
|
| 451 | 451 | foreach ($builderCache->orNotBetween as $field => $clause) {
|
| 452 | - $builderCache->orWhere[ $field ][ '$not' ] = [ |
|
| 453 | - '$gte' => $clause[ 'start' ], |
|
| 454 | - '$lte' => $clause[ 'end' ], |
|
| 452 | + $builderCache->orWhere[$field]['$not'] = [ |
|
| 453 | + '$gte' => $clause['start'], |
|
| 454 | + '$lte' => $clause['end'], |
|
| 455 | 455 | ]; |
| 456 | 456 | } |
| 457 | 457 | } |
@@ -489,7 +489,7 @@ discard block |
||
| 489 | 489 | $sort = []; |
| 490 | 490 | foreach ($builderCache->orderBy as $field => $direction) {
|
| 491 | 491 | $direction = $direction === 'ASC' ? 1 : -1; |
| 492 | - $sort[ $field ] = $direction; |
|
| 492 | + $sort[$field] = $direction; |
|
| 493 | 493 | } |
| 494 | 494 | |
| 495 | 495 | $statement->addOption('sort', $sort);
|
@@ -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 | } |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | */ |
| 101 | 101 | public function __construct(AbstractConnection &$conn) |
| 102 | 102 | {
|
| 103 | - $this->conn =& $conn; |
|
| 103 | + $this->conn = & $conn; |
|
| 104 | 104 | $this->builderCache = new Query\BuilderCache(); |
| 105 | 105 | $this->cacheMode = $this->conn->getConfig('cacheEnable');
|
| 106 | 106 | } |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | $alias = empty($alias) |
| 282 | 282 | ? strtolower($type) . '_' . $field |
| 283 | 283 | : $alias; |
| 284 | - $sqlStatement = sprintf($SqlAggregateFunctions[ $type ], $field) |
|
| 284 | + $sqlStatement = sprintf($SqlAggregateFunctions[$type], $field) |
|
| 285 | 285 | . ' AS ' |
| 286 | 286 | . $this->conn->escapeIdentifiers($alias); |
| 287 | 287 | |
@@ -336,11 +336,11 @@ discard block |
||
| 336 | 336 | |
| 337 | 337 | for ($i = 0; $i < $countFieldAlias; $i++) {
|
| 338 | 338 | if ($i == 0) {
|
| 339 | - $fieldAlias[ $i ] = $fieldAlias[ $i ] . "'+"; |
|
| 339 | + $fieldAlias[$i] = $fieldAlias[$i] . "'+"; |
|
| 340 | 340 | } elseif ($i == ($countFieldAlias - 1)) {
|
| 341 | - $fieldAlias[ $i ] = "'+" . $fieldAlias[ $i ]; |
|
| 341 | + $fieldAlias[$i] = "'+" . $fieldAlias[$i]; |
|
| 342 | 342 | } else {
|
| 343 | - $fieldAlias[ $i ] = "'+" . $fieldAlias[ $i ] . "'+"; |
|
| 343 | + $fieldAlias[$i] = "'+" . $fieldAlias[$i] . "'+"; |
|
| 344 | 344 | } |
| 345 | 345 | } |
| 346 | 346 | |
@@ -492,7 +492,7 @@ discard block |
||
| 492 | 492 | |
| 493 | 493 | $this->select( |
| 494 | 494 | sprintf( |
| 495 | - $SqlScalarFunctions[ $type ], |
|
| 495 | + $SqlScalarFunctions[$type], |
|
| 496 | 496 | $field, |
| 497 | 497 | $this->conn->escapeIdentifiers($alias) |
| 498 | 498 | ) |
@@ -697,7 +697,7 @@ discard block |
||
| 697 | 697 | |
| 698 | 698 | if (is_array($field)) {
|
| 699 | 699 | $fieldName = key($field); |
| 700 | - $fieldAlias = $field[ $fieldName ]; |
|
| 700 | + $fieldAlias = $field[$fieldName]; |
|
| 701 | 701 | } elseif (strpos($field, ' AS ') !== false) {
|
| 702 | 702 | $xField = explode(' AS ', $field);
|
| 703 | 703 | $xField = array_map('trim', $xField);
|
@@ -904,7 +904,7 @@ discard block |
||
| 904 | 904 | public function dateDiff(array $fields, $alias) |
| 905 | 905 | {
|
| 906 | 906 | $dateTimeStart = key($fields); |
| 907 | - $dateTimeEnd = $fields[ $dateTimeStart ]; |
|
| 907 | + $dateTimeEnd = $fields[$dateTimeStart]; |
|
| 908 | 908 | |
| 909 | 909 | if (preg_match("/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/", $dateTimeStart)) {
|
| 910 | 910 | $dateTimeStart = $this->conn->escape($dateTimeStart); |
@@ -1098,14 +1098,14 @@ discard block |
||
| 1098 | 1098 | // Split multiple conditions |
| 1099 | 1099 | if (preg_match_all('/\sAND\s|\sOR\s/i', $condition, $joints, PREG_OFFSET_CAPTURE)) {
|
| 1100 | 1100 | $conditions = []; |
| 1101 | - $joints = $joints[ 0 ]; |
|
| 1101 | + $joints = $joints[0]; |
|
| 1102 | 1102 | array_unshift($joints, ['', 0]); |
| 1103 | 1103 | |
| 1104 | 1104 | for ($i = count($joints) - 1, $pos = strlen($condition); $i >= 0; $i--) {
|
| 1105 | - $joints[ $i ][ 1 ] += strlen($joints[ $i ][ 0 ]); // offset |
|
| 1106 | - $conditions[ $i ] = substr($condition, $joints[ $i ][ 1 ], $pos - $joints[ $i ][ 1 ]); |
|
| 1107 | - $pos = $joints[ $i ][ 1 ] - strlen($joints[ $i ][ 0 ]); |
|
| 1108 | - $joints[ $i ] = $joints[ $i ][ 0 ]; |
|
| 1105 | + $joints[$i][1] += strlen($joints[$i][0]); // offset |
|
| 1106 | + $conditions[$i] = substr($condition, $joints[$i][1], $pos - $joints[$i][1]); |
|
| 1107 | + $pos = $joints[$i][1] - strlen($joints[$i][0]); |
|
| 1108 | + $joints[$i] = $joints[$i][0]; |
|
| 1109 | 1109 | } |
| 1110 | 1110 | } else {
|
| 1111 | 1111 | $conditions = [$condition]; |
@@ -1114,17 +1114,17 @@ discard block |
||
| 1114 | 1114 | |
| 1115 | 1115 | $condition = ' ON '; |
| 1116 | 1116 | for ($i = 0, $c = count($conditions); $i < $c; $i++) {
|
| 1117 | - $operator = $this->getOperator($conditions[ $i ]); |
|
| 1118 | - $condition .= $joints[ $i ]; |
|
| 1117 | + $operator = $this->getOperator($conditions[$i]); |
|
| 1118 | + $condition .= $joints[$i]; |
|
| 1119 | 1119 | $condition .= preg_match( |
| 1120 | 1120 | "/(\(*)?([\[\]\w\.'-]+)" . preg_quote($operator) . "(.*)/i", |
| 1121 | - $conditions[ $i ], |
|
| 1121 | + $conditions[$i], |
|
| 1122 | 1122 | $match |
| 1123 | 1123 | ) |
| 1124 | - ? $match[ 1 ] . $this->conn->protectIdentifiers( |
|
| 1125 | - $match[ 2 ] |
|
| 1126 | - ) . $operator . $this->conn->protectIdentifiers($match[ 3 ]) |
|
| 1127 | - : $conditions[ $i ]; |
|
| 1124 | + ? $match[1] . $this->conn->protectIdentifiers( |
|
| 1125 | + $match[2] |
|
| 1126 | + ) . $operator . $this->conn->protectIdentifiers($match[3]) |
|
| 1127 | + : $conditions[$i]; |
|
| 1128 | 1128 | } |
| 1129 | 1129 | } |
| 1130 | 1130 | |
@@ -1188,23 +1188,23 @@ discard block |
||
| 1188 | 1188 | : ''; |
| 1189 | 1189 | |
| 1190 | 1190 | $operator = [ |
| 1191 | - '\s*(?:<|>|!)?=\s*', // =, <=, >=, != |
|
| 1192 | - '\s*<>?\s*', // <, <> |
|
| 1193 | - '\s*>\s*', // > |
|
| 1194 | - '\s+IS NULL', // IS NULL |
|
| 1195 | - '\s+IS NOT NULL', // IS NOT NULL |
|
| 1196 | - '\s+EXISTS\s*\(.*\)', // EXISTS(Sql) |
|
| 1197 | - '\s+NOT EXISTS\s*\(.*\)', // NOT EXISTS(Sql) |
|
| 1198 | - '\s+BETWEEN\s+', // BETWEEN value AND value |
|
| 1199 | - '\s+IN\s*\(.*\)', // IN(list) |
|
| 1200 | - '\s+NOT IN\s*\(.*\)', // NOT IN (list) |
|
| 1201 | - '\s+LIKE\s+\S.*(' . $likeEscapeString . ')?', // LIKE 'expr'[ ESCAPE '%s']
|
|
| 1191 | + '\s*(?:<|>|!)?=\s*', // =, <=, >=, != |
|
| 1192 | + '\s*<>?\s*', // <, <> |
|
| 1193 | + '\s*>\s*', // > |
|
| 1194 | + '\s+IS NULL', // IS NULL |
|
| 1195 | + '\s+IS NOT NULL', // IS NOT NULL |
|
| 1196 | + '\s+EXISTS\s*\(.*\)', // EXISTS(Sql) |
|
| 1197 | + '\s+NOT EXISTS\s*\(.*\)', // NOT EXISTS(Sql) |
|
| 1198 | + '\s+BETWEEN\s+', // BETWEEN value AND value |
|
| 1199 | + '\s+IN\s*\(.*\)', // IN(list) |
|
| 1200 | + '\s+NOT IN\s*\(.*\)', // NOT IN (list) |
|
| 1201 | + '\s+LIKE\s+\S.*(' . $likeEscapeString . ')?', // LIKE 'expr'[ ESCAPE '%s']
|
|
| 1202 | 1202 | '\s+NOT LIKE\s+\S.*(' . $likeEscapeString . ')?' // NOT LIKE 'expr'[ ESCAPE '%s']
|
| 1203 | 1203 | ]; |
| 1204 | 1204 | } |
| 1205 | 1205 | |
| 1206 | 1206 | return preg_match('/' . implode('|', $operator) . '/i', $string, $match)
|
| 1207 | - ? $match[ 0 ] |
|
| 1207 | + ? $match[0] |
|
| 1208 | 1208 | : false; |
| 1209 | 1209 | } |
| 1210 | 1210 | |
@@ -1274,8 +1274,8 @@ discard block |
||
| 1274 | 1274 | $fieldName = substr( |
| 1275 | 1275 | $fieldName, |
| 1276 | 1276 | 0, |
| 1277 | - $match[ 0 ][ 1 ] |
|
| 1278 | - ) . ($match[ 1 ][ 0 ] === '=' |
|
| 1277 | + $match[0][1] |
|
| 1278 | + ) . ($match[1][0] === '=' |
|
| 1279 | 1279 | ? ' IS NULL' |
| 1280 | 1280 | : ' IS NOT NULL'); |
| 1281 | 1281 | } elseif ($fieldValue instanceof AbstractQueryBuilder) {
|
@@ -1331,7 +1331,7 @@ discard block |
||
| 1331 | 1331 | public function bind($field, $value) |
| 1332 | 1332 | {
|
| 1333 | 1333 | if ( ! array_key_exists($field, $this->builderCache->binds)) {
|
| 1334 | - $this->builderCache->binds[ $field ] = $value; |
|
| 1334 | + $this->builderCache->binds[$field] = $value; |
|
| 1335 | 1335 | |
| 1336 | 1336 | return $field; |
| 1337 | 1337 | } |
@@ -1342,7 +1342,7 @@ discard block |
||
| 1342 | 1342 | ++$count; |
| 1343 | 1343 | } |
| 1344 | 1344 | |
| 1345 | - $this->builderCache->binds[ $field . '_' . $count ] = $value; |
|
| 1345 | + $this->builderCache->binds[$field . '_' . $count] = $value; |
|
| 1346 | 1346 | |
| 1347 | 1347 | return $field . '_' . $count; |
| 1348 | 1348 | } |
@@ -1875,8 +1875,8 @@ discard block |
||
| 1875 | 1875 | |
| 1876 | 1876 | // Do we have a seed value? |
| 1877 | 1877 | $fields = ctype_digit((string)$fields) |
| 1878 | - ? sprintf($this->SqlOrderByRandomKeywords[ 1 ], $fields) |
|
| 1879 | - : $this->SqlOrderByRandomKeywords[ 0 ]; |
|
| 1878 | + ? sprintf($this->SqlOrderByRandomKeywords[1], $fields) |
|
| 1879 | + : $this->SqlOrderByRandomKeywords[0]; |
|
| 1880 | 1880 | } elseif (empty($fields)) {
|
| 1881 | 1881 | return $this; |
| 1882 | 1882 | } elseif ($direction !== '') {
|
@@ -1904,8 +1904,8 @@ discard block |
||
| 1904 | 1904 | PREG_OFFSET_CAPTURE |
| 1905 | 1905 | )) |
| 1906 | 1906 | ? [ |
| 1907 | - 'field' => ltrim(substr($fields, 0, $match[ 0 ][ 1 ])), |
|
| 1908 | - 'direction' => ' ' . $match[ 1 ][ 0 ], |
|
| 1907 | + 'field' => ltrim(substr($fields, 0, $match[0][1])), |
|
| 1908 | + 'direction' => ' ' . $match[1][0], |
|
| 1909 | 1909 | 'escape' => true, |
| 1910 | 1910 | ] |
| 1911 | 1911 | : ['field' => trim($fields), 'direction' => $direction, 'escape' => true]; |
@@ -2324,7 +2324,7 @@ discard block |
||
| 2324 | 2324 | if (count($this->builderCache->sets)) {
|
| 2325 | 2325 | $sqlStatement = $this->platformInsertStatement( |
| 2326 | 2326 | $this->conn->protectIdentifiers( |
| 2327 | - $this->builderCache->from[ 0 ], |
|
| 2327 | + $this->builderCache->from[0], |
|
| 2328 | 2328 | true, |
| 2329 | 2329 | $escape, |
| 2330 | 2330 | false |
@@ -2373,7 +2373,7 @@ discard block |
||
| 2373 | 2373 | foreach ($field as $key => $value) {
|
| 2374 | 2374 | if ($key === 'birthday' || $key === 'date') {
|
| 2375 | 2375 | if (is_array($value)) {
|
| 2376 | - $value = $value[ 'year' ] . '-' . $value[ 'month' ] . '-' . $value[ 'date' ]; |
|
| 2376 | + $value = $value['year'] . '-' . $value['month'] . '-' . $value['date']; |
|
| 2377 | 2377 | } elseif (is_object($value)) {
|
| 2378 | 2378 | $value = $value->year . '-' . $value->month . '-' . $value->date; |
| 2379 | 2379 | } |
@@ -2381,9 +2381,9 @@ discard block |
||
| 2381 | 2381 | $value = call_user_func_array($this->arrayObjectConversionMethod, [$value]); |
| 2382 | 2382 | } |
| 2383 | 2383 | |
| 2384 | - $this->builderCache->binds[ $key ] = $value; |
|
| 2385 | - $this->builderCache->sets[ $this->conn->protectIdentifiers($key, false, |
|
| 2386 | - $escape) ] = ':' . $key; |
|
| 2384 | + $this->builderCache->binds[$key] = $value; |
|
| 2385 | + $this->builderCache->sets[$this->conn->protectIdentifiers($key, false, |
|
| 2386 | + $escape)] = ':' . $key; |
|
| 2387 | 2387 | } |
| 2388 | 2388 | |
| 2389 | 2389 | return $this; |
@@ -2410,7 +2410,7 @@ discard block |
||
| 2410 | 2410 | foreach (get_object_vars($object) as $key => $value) {
|
| 2411 | 2411 | // There are some built in keys we need to ignore for this conversion |
| 2412 | 2412 | if ( ! is_object($value) && ! is_array($value) && $key !== '_parent_name') {
|
| 2413 | - $array[ $key ] = $value; |
|
| 2413 | + $array[$key] = $value; |
|
| 2414 | 2414 | } |
| 2415 | 2415 | } |
| 2416 | 2416 | |
@@ -2458,7 +2458,7 @@ discard block |
||
| 2458 | 2458 | $affectedRows = 0; |
| 2459 | 2459 | for ($i = 0, $total = count($sets); $i < $total; $i += $batchSize) {
|
| 2460 | 2460 | $Sql = $this->platformInsertBatchStatement( |
| 2461 | - $this->conn->protectIdentifiers($this->builderCache->from[ 0 ], true, $escape, false), |
|
| 2461 | + $this->conn->protectIdentifiers($this->builderCache->from[0], true, $escape, false), |
|
| 2462 | 2462 | $this->builderCache->keys, |
| 2463 | 2463 | array_slice($this->builderCache->sets, $i, $batchSize) |
| 2464 | 2464 | ); |
@@ -2559,8 +2559,8 @@ discard block |
||
| 2559 | 2559 | // There are some built in keys we need to ignore for this conversion |
| 2560 | 2560 | if ($field !== '_parent_name') {
|
| 2561 | 2561 | $i = 0; |
| 2562 | - foreach ($out[ $field ] as $data) {
|
|
| 2563 | - $array[ $i++ ][ $field ] = $data; |
|
| 2562 | + foreach ($out[$field] as $data) {
|
|
| 2563 | + $array[$i++][$field] = $data; |
|
| 2564 | 2564 | } |
| 2565 | 2565 | } |
| 2566 | 2566 | } |
@@ -2611,7 +2611,7 @@ discard block |
||
| 2611 | 2611 | if (count($this->builderCache->sets)) {
|
| 2612 | 2612 | $sqlStatement = $this->platformReplaceStatement( |
| 2613 | 2613 | $this->conn->protectIdentifiers( |
| 2614 | - $this->builderCache->from[ 0 ], |
|
| 2614 | + $this->builderCache->from[0], |
|
| 2615 | 2615 | true, |
| 2616 | 2616 | $escape, |
| 2617 | 2617 | false |
@@ -2674,7 +2674,7 @@ discard block |
||
| 2674 | 2674 | $affectedRows = 0; |
| 2675 | 2675 | for ($i = 0, $total = count($sets); $i < $total; $i += $batchSize) {
|
| 2676 | 2676 | $Sql = $this->platformReplaceStatement( |
| 2677 | - $this->conn->protectIdentifiers($this->builderCache->from[ 0 ], true, $escape, false), |
|
| 2677 | + $this->conn->protectIdentifiers($this->builderCache->from[0], true, $escape, false), |
|
| 2678 | 2678 | $this->builderCache->keys, |
| 2679 | 2679 | array_slice($this->builderCache->sets, $i, $batchSize) |
| 2680 | 2680 | ); |
@@ -2726,7 +2726,7 @@ discard block |
||
| 2726 | 2726 | if (count($this->builderCache->sets) && count($this->builderCache->from)) {
|
| 2727 | 2727 | $sqlStatement = $this->platformUpdateStatement( |
| 2728 | 2728 | $this->conn->protectIdentifiers( |
| 2729 | - $this->builderCache->from[ 0 ], |
|
| 2729 | + $this->builderCache->from[0], |
|
| 2730 | 2730 | true, |
| 2731 | 2731 | $escape, |
| 2732 | 2732 | false |
@@ -2787,7 +2787,7 @@ discard block |
||
| 2787 | 2787 | $affectedRows = 0; |
| 2788 | 2788 | for ($i = 0, $total = count($this->builderCache->sets); $i < $total; $i += $batchSize) {
|
| 2789 | 2789 | $sql = $this->platformUpdateBatchStatement( |
| 2790 | - $this->builderCache->from[ 0 ], |
|
| 2790 | + $this->builderCache->from[0], |
|
| 2791 | 2791 | array_slice($this->builderCache->sets, $i, $batchSize), |
| 2792 | 2792 | $this->conn->protectIdentifiers($index, false, $escape, false) |
| 2793 | 2793 | ); |
@@ -2799,7 +2799,7 @@ discard block |
||
| 2799 | 2799 | $affectedRows += $this->conn->getAffectedRows(); |
| 2800 | 2800 | } |
| 2801 | 2801 | |
| 2802 | - $this->builderCache[ 'where' ] = []; |
|
| 2802 | + $this->builderCache['where'] = []; |
|
| 2803 | 2803 | } |
| 2804 | 2804 | |
| 2805 | 2805 | if ( ! $this->testMode) {
|
@@ -2843,7 +2843,7 @@ discard block |
||
| 2843 | 2843 | |
| 2844 | 2844 | $bind = $this->bind($key, $value); |
| 2845 | 2845 | |
| 2846 | - $row[ $this->conn->protectIdentifiers($key, false, $escape) ] = ':' . $bind; |
|
| 2846 | + $row[$this->conn->protectIdentifiers($key, false, $escape)] = ':' . $bind; |
|
| 2847 | 2847 | } |
| 2848 | 2848 | |
| 2849 | 2849 | if ($indexSet === false) {
|
@@ -2894,7 +2894,7 @@ discard block |
||
| 2894 | 2894 | |
| 2895 | 2895 | $sqlStatement = $this->platformDeleteStatement( |
| 2896 | 2896 | $this->conn->protectIdentifiers( |
| 2897 | - $this->builderCache->from[ 0 ], |
|
| 2897 | + $this->builderCache->from[0], |
|
| 2898 | 2898 | true, |
| 2899 | 2899 | $this->conn->protectIdentifiers, |
| 2900 | 2900 | false |
@@ -3073,10 +3073,10 @@ discard block |
||
| 3073 | 3073 | // The reason we protect identifiers here rather than in the select() function |
| 3074 | 3074 | // is because until the user calls the from() function we don't know if there are aliases |
| 3075 | 3075 | foreach ($this->builderCache->select as $selectKey => $selectField) {
|
| 3076 | - $noEscape = isset($this->builderCache->noEscape [ $selectKey ]) |
|
| 3077 | - ? $this->builderCache->noEscape [ $selectKey ] |
|
| 3076 | + $noEscape = isset($this->builderCache->noEscape [$selectKey]) |
|
| 3077 | + ? $this->builderCache->noEscape [$selectKey] |
|
| 3078 | 3078 | : null; |
| 3079 | - $this->builderCache->select [ $selectKey ] = $this->conn->protectIdentifiers( |
|
| 3079 | + $this->builderCache->select [$selectKey] = $this->conn->protectIdentifiers( |
|
| 3080 | 3080 | $selectField, |
| 3081 | 3081 | false, |
| 3082 | 3082 | $noEscape |
@@ -3195,28 +3195,28 @@ discard block |
||
| 3195 | 3195 | if (count($this->builderCache->{$cacheKey}) > 0) {
|
| 3196 | 3196 | for ($i = 0, $c = count($this->builderCache->{$cacheKey}); $i < $c; $i++) {
|
| 3197 | 3197 | // Is this condition already compiled? |
| 3198 | - if (is_string($this->builderCache->{$cacheKey}[ $i ])) {
|
|
| 3198 | + if (is_string($this->builderCache->{$cacheKey}[$i])) {
|
|
| 3199 | 3199 | continue; |
| 3200 | - } elseif ($this->builderCache->{$cacheKey}[ $i ][ 'escape' ] === false) {
|
|
| 3201 | - $this->builderCache->{$cacheKey}[ $i ]
|
|
| 3202 | - = $this->builderCache->{$cacheKey}[ $i ][ 'condition' ];
|
|
| 3200 | + } elseif ($this->builderCache->{$cacheKey}[$i]['escape'] === false) {
|
|
| 3201 | + $this->builderCache->{$cacheKey}[$i]
|
|
| 3202 | + = $this->builderCache->{$cacheKey}[$i]['condition'];
|
|
| 3203 | 3203 | continue; |
| 3204 | 3204 | } |
| 3205 | 3205 | |
| 3206 | 3206 | // Split multiple conditions |
| 3207 | 3207 | $conditions = preg_split( |
| 3208 | 3208 | '/((?:^|\s+)AND\s+|(?:^|\s+)OR\s+)/i', |
| 3209 | - $this->builderCache->{$cacheKey}[ $i ][ 'condition' ],
|
|
| 3209 | + $this->builderCache->{$cacheKey}[$i]['condition'],
|
|
| 3210 | 3210 | -1, |
| 3211 | 3211 | PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY |
| 3212 | 3212 | ); |
| 3213 | 3213 | |
| 3214 | 3214 | for ($ci = 0, $cc = count($conditions); $ci < $cc; $ci++) {
|
| 3215 | - if (($op = $this->getOperator($conditions[ $ci ])) === false |
|
| 3215 | + if (($op = $this->getOperator($conditions[$ci])) === false |
|
| 3216 | 3216 | OR |
| 3217 | 3217 | ! preg_match( |
| 3218 | 3218 | '/^(\(?)(.*)(' . preg_quote($op, '/') . ')\s*(.*(?<!\)))?(\)?)$/i',
|
| 3219 | - $conditions[ $ci ], |
|
| 3219 | + $conditions[$ci], |
|
| 3220 | 3220 | $matches |
| 3221 | 3221 | ) |
| 3222 | 3222 | ) {
|
@@ -3232,16 +3232,16 @@ discard block |
||
| 3232 | 3232 | // 5 => ')' /* optional */ |
| 3233 | 3233 | // ); |
| 3234 | 3234 | |
| 3235 | - if ( ! empty($matches[ 4 ])) {
|
|
| 3235 | + if ( ! empty($matches[4])) {
|
|
| 3236 | 3236 | //$this->isLiteral($matches[4]) OR $matches[4] = $this->protectIdentifiers(trim($matches[4])); |
| 3237 | - $matches[ 4 ] = ' ' . $matches[ 4 ]; |
|
| 3237 | + $matches[4] = ' ' . $matches[4]; |
|
| 3238 | 3238 | } |
| 3239 | 3239 | |
| 3240 | - $conditions[ $ci ] = $matches[ 1 ] . $this->conn->protectIdentifiers(trim($matches[ 2 ])) |
|
| 3241 | - . ' ' . trim($matches[ 3 ]) . $matches[ 4 ] . $matches[ 5 ]; |
|
| 3240 | + $conditions[$ci] = $matches[1] . $this->conn->protectIdentifiers(trim($matches[2])) |
|
| 3241 | + . ' ' . trim($matches[3]) . $matches[4] . $matches[5]; |
|
| 3242 | 3242 | } |
| 3243 | 3243 | |
| 3244 | - $this->builderCache->{$cacheKey}[ $i ] = implode('', $conditions);
|
|
| 3244 | + $this->builderCache->{$cacheKey}[$i] = implode('', $conditions);
|
|
| 3245 | 3245 | } |
| 3246 | 3246 | |
| 3247 | 3247 | if ($cacheKey === 'having') {
|
@@ -3280,17 +3280,17 @@ discard block |
||
| 3280 | 3280 | if (count($this->builderCache->groupBy) > 0) {
|
| 3281 | 3281 | for ($i = 0, $c = count($this->builderCache->groupBy); $i < $c; $i++) {
|
| 3282 | 3282 | // Is it already compiled? |
| 3283 | - if (is_string($this->builderCache->groupBy[ $i ])) {
|
|
| 3283 | + if (is_string($this->builderCache->groupBy[$i])) {
|
|
| 3284 | 3284 | continue; |
| 3285 | 3285 | } |
| 3286 | 3286 | |
| 3287 | - $this->builderCache->groupBy[ $i ] = ($this->builderCache->groupBy[ $i ][ 'escape' ] |
|
| 3287 | + $this->builderCache->groupBy[$i] = ($this->builderCache->groupBy[$i]['escape'] |
|
| 3288 | 3288 | === false OR |
| 3289 | 3289 | $this->isLiteral( |
| 3290 | - $this->builderCache->groupBy[ $i ][ 'field' ] |
|
| 3290 | + $this->builderCache->groupBy[$i]['field'] |
|
| 3291 | 3291 | )) |
| 3292 | - ? $this->builderCache->groupBy[ $i ][ 'field' ] |
|
| 3293 | - : $this->conn->protectIdentifiers($this->builderCache->groupBy[ $i ][ 'field' ]); |
|
| 3292 | + ? $this->builderCache->groupBy[$i]['field'] |
|
| 3293 | + : $this->conn->protectIdentifiers($this->builderCache->groupBy[$i]['field']); |
|
| 3294 | 3294 | } |
| 3295 | 3295 | |
| 3296 | 3296 | return "\n" . sprintf( |
@@ -3335,7 +3335,7 @@ discard block |
||
| 3335 | 3335 | : ["'"]; |
| 3336 | 3336 | } |
| 3337 | 3337 | |
| 3338 | - return in_array($string[ 0 ], $stringArray, true); |
|
| 3338 | + return in_array($string[0], $stringArray, true); |
|
| 3339 | 3339 | } |
| 3340 | 3340 | |
| 3341 | 3341 | //-------------------------------------------------------------------- |
@@ -3393,18 +3393,18 @@ discard block |
||
| 3393 | 3393 | {
|
| 3394 | 3394 | if (is_array($this->builderCache->orderBy) && count($this->builderCache->orderBy) > 0) {
|
| 3395 | 3395 | for ($i = 0, $c = count($this->builderCache->orderBy); $i < $c; $i++) {
|
| 3396 | - if ($this->builderCache->orderBy[ $i ][ 'escape' ] !== false |
|
| 3396 | + if ($this->builderCache->orderBy[$i]['escape'] !== false |
|
| 3397 | 3397 | && ! $this->isLiteral( |
| 3398 | - $this->builderCache->orderBy[ $i ][ 'field' ] |
|
| 3398 | + $this->builderCache->orderBy[$i]['field'] |
|
| 3399 | 3399 | ) |
| 3400 | 3400 | ) {
|
| 3401 | - $this->builderCache->orderBy[ $i ][ 'field' ] = $this->conn->protectIdentifiers( |
|
| 3402 | - $this->builderCache->orderBy[ $i ][ 'field' ] |
|
| 3401 | + $this->builderCache->orderBy[$i]['field'] = $this->conn->protectIdentifiers( |
|
| 3402 | + $this->builderCache->orderBy[$i]['field'] |
|
| 3403 | 3403 | ); |
| 3404 | 3404 | } |
| 3405 | 3405 | |
| 3406 | - $this->builderCache->orderBy[ $i ] = $this->builderCache->orderBy[ $i ][ 'field' ] |
|
| 3407 | - . $this->builderCache->orderBy[ $i ][ 'direction' ]; |
|
| 3406 | + $this->builderCache->orderBy[$i] = $this->builderCache->orderBy[$i]['field'] |
|
| 3407 | + . $this->builderCache->orderBy[$i]['direction']; |
|
| 3408 | 3408 | } |
| 3409 | 3409 | |
| 3410 | 3410 | return $this->builderCache->orderBy = "\n" . sprintf( |
@@ -41,7 +41,7 @@ |
||
| 41 | 41 | */ |
| 42 | 42 | public function __construct(AbstractConnection &$conn) |
| 43 | 43 | { |
| 44 | - $this->conn =& $conn; |
|
| 44 | + $this->conn = & $conn; |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | // ------------------------------------------------------------------------ |
@@ -123,9 +123,9 @@ discard block |
||
| 123 | 123 | */ |
| 124 | 124 | public function getDatabases() |
| 125 | 125 | {
|
| 126 | - $this->queriesResultCache[ 'databaseNames' ][] = pathinfo($this->database, PATHINFO_FILENAME); |
|
| 126 | + $this->queriesResultCache['databaseNames'][] = pathinfo($this->database, PATHINFO_FILENAME); |
|
| 127 | 127 | |
| 128 | - return $this->queriesResultCache[ 'databaseNames' ]; |
|
| 128 | + return $this->queriesResultCache['databaseNames']; |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | // ------------------------------------------------------------------------ |
@@ -143,12 +143,12 @@ discard block |
||
| 143 | 143 | */ |
| 144 | 144 | public function getTables($prefixLimit = false) |
| 145 | 145 | {
|
| 146 | - if (empty($this->queriesResultCache[ 'tableNames' ])) {
|
|
| 146 | + if (empty($this->queriesResultCache['tableNames'])) {
|
|
| 147 | 147 | |
| 148 | 148 | $sqlStatement = 'SELECT "NAME" FROM "SQLITE_MASTER" WHERE "TYPE" = \'table\''; |
| 149 | 149 | |
| 150 | - if ($prefixLimit !== false && $this->config[ 'tablePrefix' ] !== '') {
|
|
| 151 | - $sqlStatement .= ' AND "NAME" LIKE \'' . $this->escapeLikeString($this->config[ 'tablePrefix' ]) . "%' "; |
|
| 150 | + if ($prefixLimit !== false && $this->config['tablePrefix'] !== '') {
|
|
| 151 | + $sqlStatement .= ' AND "NAME" LIKE \'' . $this->escapeLikeString($this->config['tablePrefix']) . "%' "; |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | $result = $this->query($sqlStatement); |
@@ -157,9 +157,9 @@ discard block |
||
| 157 | 157 | foreach ($result as $row) {
|
| 158 | 158 | // Do we know from which column to get the table name? |
| 159 | 159 | if ( ! isset($key)) {
|
| 160 | - if (isset($row[ 'table_name' ])) {
|
|
| 160 | + if (isset($row['table_name'])) {
|
|
| 161 | 161 | $key = 'table_name'; |
| 162 | - } elseif (isset($row[ 'TABLE_NAME' ])) {
|
|
| 162 | + } elseif (isset($row['TABLE_NAME'])) {
|
|
| 163 | 163 | $key = 'TABLE_NAME'; |
| 164 | 164 | } else {
|
| 165 | 165 | /* We have no other choice but to just get the first element's key. |
@@ -172,12 +172,12 @@ discard block |
||
| 172 | 172 | } |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | - $this->queriesResultCache[ 'tableNames' ][] = $row->offsetGet($key); |
|
| 175 | + $this->queriesResultCache['tableNames'][] = $row->offsetGet($key); |
|
| 176 | 176 | } |
| 177 | 177 | } |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - return $this->queriesResultCache[ 'tableNames' ]; |
|
| 180 | + return $this->queriesResultCache['tableNames']; |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | // ------------------------------------------------------------------------ |
@@ -195,24 +195,24 @@ discard block |
||
| 195 | 195 | {
|
| 196 | 196 | $table = $this->prefixTable($table); |
| 197 | 197 | |
| 198 | - if (empty($this->queriesResultCache[ 'tableColumns' ][ $table ])) {
|
|
| 198 | + if (empty($this->queriesResultCache['tableColumns'][$table])) {
|
|
| 199 | 199 | $result = $this->query('PRAGMA TABLE_INFO(' . $this->protectIdentifiers($table, true, null, false) . ')');
|
| 200 | 200 | |
| 201 | 201 | if ($result->count()) {
|
| 202 | 202 | foreach ($result as $row) {
|
| 203 | 203 | // Do we know from where to get the column's name? |
| 204 | 204 | if ( ! isset($key)) {
|
| 205 | - if (isset($row[ 'name' ])) {
|
|
| 205 | + if (isset($row['name'])) {
|
|
| 206 | 206 | $key = 'name'; |
| 207 | 207 | } |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | - $this->queriesResultCache[ 'tableColumns' ][ $table ][ $row->offsetGet($key) ] = $row; |
|
| 210 | + $this->queriesResultCache['tableColumns'][$table][$row->offsetGet($key)] = $row; |
|
| 211 | 211 | } |
| 212 | 212 | } |
| 213 | 213 | } |
| 214 | 214 | |
| 215 | - return $this->queriesResultCache[ 'tableColumns' ][ $table ]; |
|
| 215 | + return $this->queriesResultCache['tableColumns'][$table]; |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | // ------------------------------------------------------------------------ |
@@ -331,7 +331,7 @@ discard block |
||
| 331 | 331 | if (false !== ($result = $this->handle->query($statement->getSqlFinalStatement()))) {
|
| 332 | 332 | $i = 0; |
| 333 | 333 | while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
|
| 334 | - $rows[ $i ] = $row; |
|
| 334 | + $rows[$i] = $row; |
|
| 335 | 335 | $i++; |
| 336 | 336 | } |
| 337 | 337 | } else {
|
@@ -86,84 +86,84 @@ discard block |
||
| 86 | 86 | // Columns Statement |
| 87 | 87 | $columnStatements = []; |
| 88 | 88 | foreach ($columns as $columnName => $columnAttributes) { |
| 89 | - if (isset($columnAttributes[ 'type' ])) { |
|
| 90 | - if (isset($columnAttributes[ 'foreign_key' ])) { |
|
| 91 | - $foreignKeys[ $columnName ] = $columnAttributes[ 'foreign_key' ]; |
|
| 89 | + if (isset($columnAttributes['type'])) { |
|
| 90 | + if (isset($columnAttributes['foreign_key'])) { |
|
| 91 | + $foreignKeys[$columnName] = $columnAttributes['foreign_key']; |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | $columnStatementLine = []; |
| 95 | 95 | $columnName = $this->conn->escapeIdentifiers($columnName); |
| 96 | - $columnAttributes[ 'type' ] = strtoupper($columnAttributes[ 'type' ]); |
|
| 96 | + $columnAttributes['type'] = strtoupper($columnAttributes['type']); |
|
| 97 | 97 | |
| 98 | - if (isset($columnAttributes[ 'primary_key' ])) { |
|
| 99 | - if ($columnAttributes[ 'primary_key' ] === true) { |
|
| 98 | + if (isset($columnAttributes['primary_key'])) { |
|
| 99 | + if ($columnAttributes['primary_key'] === true) { |
|
| 100 | 100 | $primaryKeys[] = $columnName; |
| 101 | 101 | } |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | - if (isset($columnAttributes[ 'unique' ])) { |
|
| 105 | - if ($columnAttributes[ 'unique' ] === true) { |
|
| 104 | + if (isset($columnAttributes['unique'])) { |
|
| 105 | + if ($columnAttributes['unique'] === true) { |
|
| 106 | 106 | $uniqueKeys[] = $columnName; |
| 107 | 107 | } |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - if ($columnAttributes[ 'type' ] === 'ENUM') { |
|
| 111 | - if (empty($columnAttributes[ 'value' ])) { |
|
| 110 | + if ($columnAttributes['type'] === 'ENUM') { |
|
| 111 | + if (empty($columnAttributes['value'])) { |
|
| 112 | 112 | continue; |
| 113 | 113 | } else { |
| 114 | - if (is_string($columnAttributes[ 'value' ])) { |
|
| 115 | - $columnAttributes[ 'value' ] = explode(',', $columnAttributes[ 'value' ]); |
|
| 114 | + if (is_string($columnAttributes['value'])) { |
|
| 115 | + $columnAttributes['value'] = explode(',', $columnAttributes['value']); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - $columnAttributes[ 'value' ] = array_map(function ($value) { |
|
| 118 | + $columnAttributes['value'] = array_map(function($value) { |
|
| 119 | 119 | return $this->conn->escape(str_replace('\'', '', trim($value))); |
| 120 | - }, $columnAttributes[ 'value' ]); |
|
| 120 | + }, $columnAttributes['value']); |
|
| 121 | 121 | |
| 122 | 122 | $columnStatementLine[] = $columnName . |
| 123 | - ' ' . $columnAttributes[ 'type' ] . '(' . |
|
| 124 | - implode(',', $columnAttributes[ 'value' ]) |
|
| 123 | + ' ' . $columnAttributes['type'] . '(' . |
|
| 124 | + implode(',', $columnAttributes['value']) |
|
| 125 | 125 | . ')'; |
| 126 | 126 | } |
| 127 | - } elseif (isset($columnAttributes[ 'length' ])) { |
|
| 128 | - $columnStatementLine[] = $columnName . ' ' . $columnAttributes[ 'type' ] . '(' . $columnAttributes[ 'length' ] . ')'; |
|
| 127 | + } elseif (isset($columnAttributes['length'])) { |
|
| 128 | + $columnStatementLine[] = $columnName . ' ' . $columnAttributes['type'] . '(' . $columnAttributes['length'] . ')'; |
|
| 129 | 129 | } else { |
| 130 | - $columnStatementLine[] = $columnName . ' ' . $columnAttributes[ 'type' ]; |
|
| 130 | + $columnStatementLine[] = $columnName . ' ' . $columnAttributes['type']; |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - if (isset($columnAttributes[ 'unsigned' ])) { |
|
| 134 | - if ($columnAttributes[ 'unsigned' ] === true) { |
|
| 135 | - if (in_array($columnAttributes[ 'type' ], |
|
| 133 | + if (isset($columnAttributes['unsigned'])) { |
|
| 134 | + if ($columnAttributes['unsigned'] === true) { |
|
| 135 | + if (in_array($columnAttributes['type'], |
|
| 136 | 136 | ['INT', 'BIGINT', 'SMALLINT', 'TINYINT', 'FLOAT', 'DECIMAL', 'REAL'])) { |
| 137 | 137 | $columnStatementLine[] = 'UNSIGNED'; |
| 138 | 138 | } |
| 139 | 139 | } |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - if (isset($columnAttributes[ 'collate' ])) { |
|
| 143 | - $columnStatementLine[] = 'COLLATE ' . $columnAttributes[ 'collate' ]; |
|
| 144 | - } elseif (in_array($columnAttributes[ 'type' ], |
|
| 142 | + if (isset($columnAttributes['collate'])) { |
|
| 143 | + $columnStatementLine[] = 'COLLATE ' . $columnAttributes['collate']; |
|
| 144 | + } elseif (in_array($columnAttributes['type'], |
|
| 145 | 145 | ['CHAR', 'VARCHAR', 'TEXT', 'LONGTEXT', 'TINYTEXT', 'ENUM'])) { |
| 146 | 146 | $columnStatementLine[] = 'COLLATE ' . $this->conn->getConfig('collate'); |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | - if (isset($columnAttributes[ 'not_null' ])) { |
|
| 150 | - if ($columnAttributes[ 'not_null' ] === true) { |
|
| 149 | + if (isset($columnAttributes['not_null'])) { |
|
| 150 | + if ($columnAttributes['not_null'] === true) { |
|
| 151 | 151 | $columnStatementLine[] = 'NOT NULL'; |
| 152 | 152 | } |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | - if (isset($columnAttributes[ 'default' ])) { |
|
| 156 | - $columnStatementLine[] = 'DEFAULT ' . $this->conn->escape($columnAttributes[ 'default' ]); |
|
| 155 | + if (isset($columnAttributes['default'])) { |
|
| 156 | + $columnStatementLine[] = 'DEFAULT ' . $this->conn->escape($columnAttributes['default']); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - if (isset($columnAttributes[ 'auto_increment' ])) { |
|
| 160 | - if ($columnAttributes[ 'auto_increment' ] === true) { |
|
| 159 | + if (isset($columnAttributes['auto_increment'])) { |
|
| 160 | + if ($columnAttributes['auto_increment'] === true) { |
|
| 161 | 161 | $columnStatementLine[] = 'AUTO_INCREMENT '; |
| 162 | 162 | } |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - if (isset($columnAttributes[ 'comment' ])) { |
|
| 166 | - $columnStatementLine[] = 'COMMENT ' . $columnAttributes[ 'comment' ]; |
|
| 165 | + if (isset($columnAttributes['comment'])) { |
|
| 166 | + $columnStatementLine[] = 'COMMENT ' . $columnAttributes['comment']; |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | $columnStatements[] = "\t" . implode(' ', $columnStatementLine); |
@@ -193,16 +193,16 @@ discard block |
||
| 193 | 193 | // Foreign Keys Statement |
| 194 | 194 | if (count($foreignKeys)) { |
| 195 | 195 | foreach ($foreignKeys as $foreignKeyColumnName => $foreignKeyAttributes) { |
| 196 | - if (empty($foreignKeyAttributes[ 'name' ])) { |
|
| 197 | - $foreignKeyAttributes[ 'name' ] = 'fk_' . $foreignKeyColumnName; |
|
| 196 | + if (empty($foreignKeyAttributes['name'])) { |
|
| 197 | + $foreignKeyAttributes['name'] = 'fk_' . $foreignKeyColumnName; |
|
| 198 | 198 | } |
| 199 | 199 | |
| 200 | - if (isset($foreignKeyAttributes[ 'references' ])) { |
|
| 200 | + if (isset($foreignKeyAttributes['references'])) { |
|
| 201 | 201 | $keyStatements[] = 'KEY ' . |
| 202 | - $this->conn->escapeIdentifiers($foreignKeyAttributes[ 'name' ]) . |
|
| 202 | + $this->conn->escapeIdentifiers($foreignKeyAttributes['name']) . |
|
| 203 | 203 | ' (' . $this->conn->escapeIdentifiers($foreignKeyColumnName) . ')'; |
| 204 | 204 | |
| 205 | - $referenceParts = array_map('trim', explode('.', $foreignKeyAttributes[ 'references' ])); |
|
| 205 | + $referenceParts = array_map('trim', explode('.', $foreignKeyAttributes['references'])); |
|
| 206 | 206 | list($referenceTable, $referenceColumn) = $referenceParts; |
| 207 | 207 | |
| 208 | 208 | $referenceOnDelete = 'NO ACTION'; |
@@ -215,20 +215,20 @@ discard block |
||
| 215 | 215 | 'SET NULL', |
| 216 | 216 | ]; |
| 217 | 217 | |
| 218 | - if (isset($foreignKeyAttributes[ 'on_delete' ])) { |
|
| 219 | - if (in_array($foreignKeyAttributes[ 'on_delete' ], $validReferenceActions)) { |
|
| 220 | - $referenceOnDelete = $foreignKeyAttributes[ 'on_delete' ]; |
|
| 218 | + if (isset($foreignKeyAttributes['on_delete'])) { |
|
| 219 | + if (in_array($foreignKeyAttributes['on_delete'], $validReferenceActions)) { |
|
| 220 | + $referenceOnDelete = $foreignKeyAttributes['on_delete']; |
|
| 221 | 221 | } |
| 222 | 222 | } |
| 223 | 223 | |
| 224 | - if (isset($foreignKeyAttributes[ 'on_update' ])) { |
|
| 225 | - if (in_array($foreignKeyAttributes[ 'on_update' ], $validReferenceActions)) { |
|
| 226 | - $referenceOnUpdate = $foreignKeyAttributes[ 'on_update' ]; |
|
| 224 | + if (isset($foreignKeyAttributes['on_update'])) { |
|
| 225 | + if (in_array($foreignKeyAttributes['on_update'], $validReferenceActions)) { |
|
| 226 | + $referenceOnUpdate = $foreignKeyAttributes['on_update']; |
|
| 227 | 227 | } |
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | $constraintStatements[] = 'CONSTRAINT ' . |
| 231 | - $this->conn->escapeIdentifiers($foreignKeyAttributes[ 'name' ]) . |
|
| 231 | + $this->conn->escapeIdentifiers($foreignKeyAttributes['name']) . |
|
| 232 | 232 | ' FOREIGN KEY (' . $this->conn->escapeIdentifiers($foreignKeyColumnName) . ') REFERENCES ' . |
| 233 | 233 | $this->conn->escapeIdentifiers($referenceTable) . ' (' . $this->conn->escapeIdentifiers($referenceColumn) . |
| 234 | 234 | ') ON DELETE ' . $referenceOnDelete . ' ON UPDATE ' . $referenceOnUpdate; |
@@ -240,10 +240,10 @@ discard block |
||
| 240 | 240 | array_merge($columnStatements, $keyStatements, $constraintStatements)); |
| 241 | 241 | |
| 242 | 242 | if (empty($attributes)) { |
| 243 | - $attributes[ 'engine' ] = 'InnoDB'; |
|
| 244 | - $attributes[ 'default' ] = 'DEFAULT'; |
|
| 245 | - $attributes[ 'charset' ] = $this->conn->getConfig('charset'); |
|
| 246 | - $attributes[ 'collate' ] = $this->conn->getConfig('collate'); |
|
| 243 | + $attributes['engine'] = 'InnoDB'; |
|
| 244 | + $attributes['default'] = 'DEFAULT'; |
|
| 245 | + $attributes['charset'] = $this->conn->getConfig('charset'); |
|
| 246 | + $attributes['collate'] = $this->conn->getConfig('collate'); |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | $attributeStatements = []; |
@@ -309,63 +309,63 @@ discard block |
||
| 309 | 309 | $alterTableStatementStrings[] = strtoupper($action); |
| 310 | 310 | $alterTableStatementStrings[] = $this->conn->escapeIdentifiers($column); |
| 311 | 311 | |
| 312 | - if (isset($attributes[ 'type' ])) { |
|
| 313 | - if ($attributes[ 'type' ] === 'ENUM') { |
|
| 314 | - if (empty($attributes[ 'value' ])) { |
|
| 312 | + if (isset($attributes['type'])) { |
|
| 313 | + if ($attributes['type'] === 'ENUM') { |
|
| 314 | + if (empty($attributes['value'])) { |
|
| 315 | 315 | return false; |
| 316 | 316 | } else { |
| 317 | - if (is_string($attributes[ 'value' ])) { |
|
| 318 | - $attributes[ 'value' ] = explode(',', $attributes[ 'value' ]); |
|
| 317 | + if (is_string($attributes['value'])) { |
|
| 318 | + $attributes['value'] = explode(',', $attributes['value']); |
|
| 319 | 319 | } |
| 320 | 320 | |
| 321 | - $attributes[ 'value' ] = array_map(function ($value) { |
|
| 321 | + $attributes['value'] = array_map(function($value) { |
|
| 322 | 322 | return $this->conn->escape(str_replace('\'', '', trim($value))); |
| 323 | - }, $attributes[ 'value' ]); |
|
| 323 | + }, $attributes['value']); |
|
| 324 | 324 | |
| 325 | - $alterTableStatementStrings[] = $attributes[ 'type' ] . '(' . |
|
| 326 | - implode(',', $attributes[ 'value' ]) |
|
| 325 | + $alterTableStatementStrings[] = $attributes['type'] . '(' . |
|
| 326 | + implode(',', $attributes['value']) |
|
| 327 | 327 | . ')'; |
| 328 | 328 | } |
| 329 | - } elseif (isset($attributes[ 'length' ])) { |
|
| 330 | - $alterTableStatementStrings[] = $attributes[ 'type' ] . '(' . $attributes[ 'length' ] . ')'; |
|
| 329 | + } elseif (isset($attributes['length'])) { |
|
| 330 | + $alterTableStatementStrings[] = $attributes['type'] . '(' . $attributes['length'] . ')'; |
|
| 331 | 331 | } else { |
| 332 | - $alterTableStatementStrings[] = $attributes[ 'type' ]; |
|
| 332 | + $alterTableStatementStrings[] = $attributes['type']; |
|
| 333 | 333 | } |
| 334 | 334 | |
| 335 | - if (isset($attributes[ 'unsigned' ])) { |
|
| 336 | - if ($attributes[ 'unsigned' ] === true) { |
|
| 337 | - if (in_array($attributes[ 'type' ], |
|
| 335 | + if (isset($attributes['unsigned'])) { |
|
| 336 | + if ($attributes['unsigned'] === true) { |
|
| 337 | + if (in_array($attributes['type'], |
|
| 338 | 338 | ['INT', 'BIGINT', 'SMALLINT', 'TINYINT', 'FLOAT', 'DECIMAL', 'REAL'])) { |
| 339 | 339 | $alterTableStatementStrings[] = 'UNSIGNED'; |
| 340 | 340 | } |
| 341 | 341 | } |
| 342 | 342 | } |
| 343 | 343 | |
| 344 | - if (isset($attributes[ 'collate' ])) { |
|
| 345 | - $alterTableStatementStrings[] = 'COLLATE ' . $attributes[ 'collate' ]; |
|
| 346 | - } elseif (in_array($attributes[ 'type' ], |
|
| 344 | + if (isset($attributes['collate'])) { |
|
| 345 | + $alterTableStatementStrings[] = 'COLLATE ' . $attributes['collate']; |
|
| 346 | + } elseif (in_array($attributes['type'], |
|
| 347 | 347 | ['CHAR', 'VARCHAR', 'TEXT', 'LONGTEXT', 'TINYTEXT', 'ENUM'])) { |
| 348 | 348 | $alterTableStatementStrings[] = 'COLLATE ' . $this->conn->getConfig('collate'); |
| 349 | 349 | } |
| 350 | 350 | |
| 351 | - if (isset($attributes[ 'not_null' ])) { |
|
| 352 | - if ($attributes[ 'not_null' ] === true) { |
|
| 351 | + if (isset($attributes['not_null'])) { |
|
| 352 | + if ($attributes['not_null'] === true) { |
|
| 353 | 353 | $alterTableStatementStrings[] = 'NOT NULL'; |
| 354 | 354 | } |
| 355 | 355 | } |
| 356 | 356 | |
| 357 | - if (isset($attributes[ 'default' ])) { |
|
| 358 | - $alterTableStatementStrings[] = 'DEFAULT ' . $this->conn->escape($attributes[ 'default' ]); |
|
| 357 | + if (isset($attributes['default'])) { |
|
| 358 | + $alterTableStatementStrings[] = 'DEFAULT ' . $this->conn->escape($attributes['default']); |
|
| 359 | 359 | } |
| 360 | 360 | |
| 361 | - if (isset($attributes[ 'auto_increment' ])) { |
|
| 362 | - if ($attributes[ 'auto_increment' ] === true) { |
|
| 361 | + if (isset($attributes['auto_increment'])) { |
|
| 362 | + if ($attributes['auto_increment'] === true) { |
|
| 363 | 363 | $alterTableStatementStrings[] = 'AUTO_INCREMENT '; |
| 364 | 364 | } |
| 365 | 365 | } |
| 366 | 366 | |
| 367 | - if (isset($attributes[ 'comment' ])) { |
|
| 368 | - $alterTableStatementStrings[] = 'COMMENT ' . $attributes[ 'comment' ]; |
|
| 367 | + if (isset($attributes['comment'])) { |
|
| 368 | + $alterTableStatementStrings[] = 'COMMENT ' . $attributes['comment']; |
|
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | $statementLines[] = implode(' ', $alterTableStatementStrings) . ';'; |
@@ -406,7 +406,7 @@ discard block |
||
| 406 | 406 | { |
| 407 | 407 | $statementLines[] = 'ALTER TABLE ' . $this->conn->escapeIdentifiers($table); |
| 408 | 408 | |
| 409 | - $keys = array_map(function ($column) { |
|
| 409 | + $keys = array_map(function($column) { |
|
| 410 | 410 | return $this->conn->escapeIdentifiers($column); |
| 411 | 411 | }, $columns); |
| 412 | 412 | |
@@ -479,7 +479,7 @@ discard block |
||
| 479 | 479 | { |
| 480 | 480 | $statementLines[] = 'ALTER TABLE ' . $this->conn->escapeIdentifiers($table); |
| 481 | 481 | |
| 482 | - $keys = array_map(function ($column) { |
|
| 482 | + $keys = array_map(function($column) { |
|
| 483 | 483 | return $this->conn->escapeIdentifiers($column); |
| 484 | 484 | }, $columns); |
| 485 | 485 | |
@@ -507,7 +507,7 @@ discard block |
||
| 507 | 507 | */ |
| 508 | 508 | protected function platformCreateTableIndexesStatement($table, array $columns, $unique = false) |
| 509 | 509 | { |
| 510 | - $keys = array_map(function ($column) { |
|
| 510 | + $keys = array_map(function($column) { |
|
| 511 | 511 | return $this->conn->escapeIdentifiers($column); |
| 512 | 512 | }, $columns); |
| 513 | 513 | |
@@ -590,13 +590,13 @@ discard block |
||
| 590 | 590 | $columns = array_keys($conditions); |
| 591 | 591 | |
| 592 | 592 | if (count($conditions) == 1) { |
| 593 | - $statementLines[] = 'ADD CHECK (' . $this->conn->escapeIdentifiers($columns[ 0 ]) . ')'; |
|
| 593 | + $statementLines[] = 'ADD CHECK (' . $this->conn->escapeIdentifiers($columns[0]) . ')'; |
|
| 594 | 594 | } else { |
| 595 | 595 | $conditionStatementStrings = []; |
| 596 | 596 | |
| 597 | 597 | foreach ($conditions as $column => $condition) { |
| 598 | 598 | if (preg_match('/\s*(?:<|>|!)?=\s*|\s*<>?\s*|\s*>\s*/i', $column, $match, PREG_OFFSET_CAPTURE)) { |
| 599 | - $operator = trim($match[ 0 ]); |
|
| 599 | + $operator = trim($match[0]); |
|
| 600 | 600 | $column = trim(str_replace($operator, '', $column)); |
| 601 | 601 | |
| 602 | 602 | $conditionStatementStrings[] = $this->conn->escapeIdentifiers($column) . $operator . $this->conn->escape($condition); |