@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | 'pages' => 0, |
43 | 43 | ], $total)); |
44 | 44 | |
45 | - if(isset($total['limit'])) { |
|
45 | + if (isset($total['limit'])) { |
|
46 | 46 | $this->limit = $total['limit']; |
47 | 47 | } |
48 | 48 | |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | $this->limit = (int)$limit; |
76 | 76 | $this->total->pages = 1; |
77 | 77 | |
78 | - if($this->limit > 0) { |
|
78 | + if ($this->limit > 0) { |
|
79 | 79 | $this->total->pages = @ceil($this->total->rows / $this->limit); |
80 | 80 | } |
81 | 81 |
@@ -203,7 +203,7 @@ |
||
203 | 203 | */ |
204 | 204 | public function setError($errorCode, $errorMessage) |
205 | 205 | { |
206 | - $this->error[ $errorCode ] = $errorMessage; |
|
206 | + $this->error[$errorCode] = $errorMessage; |
|
207 | 207 | |
208 | 208 | return $this; |
209 | 209 | } |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | */ |
102 | 102 | public function __construct(AbstractConnection &$conn) |
103 | 103 | { |
104 | - $this->conn =& $conn; |
|
104 | + $this->conn = & $conn; |
|
105 | 105 | $this->builderCache = new QueryBuilderCache(); |
106 | 106 | $this->cacheMode = $this->conn->getConfig('cacheEnable'); |
107 | 107 | } |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | $alias = empty($alias) |
283 | 283 | ? strtolower($type) . '_' . $field |
284 | 284 | : $alias; |
285 | - $sqlStatement = sprintf($SqlAggregateFunctions[ $type ], $field) |
|
285 | + $sqlStatement = sprintf($SqlAggregateFunctions[$type], $field) |
|
286 | 286 | . ' AS ' |
287 | 287 | . $this->conn->escapeIdentifiers($alias); |
288 | 288 | |
@@ -337,11 +337,11 @@ discard block |
||
337 | 337 | |
338 | 338 | for ($i = 0; $i < $countFieldAlias; $i++) { |
339 | 339 | if ($i == 0) { |
340 | - $fieldAlias[ $i ] = $fieldAlias[ $i ] . "'+"; |
|
340 | + $fieldAlias[$i] = $fieldAlias[$i] . "'+"; |
|
341 | 341 | } elseif ($i == ($countFieldAlias - 1)) { |
342 | - $fieldAlias[ $i ] = "'+" . $fieldAlias[ $i ]; |
|
342 | + $fieldAlias[$i] = "'+" . $fieldAlias[$i]; |
|
343 | 343 | } else { |
344 | - $fieldAlias[ $i ] = "'+" . $fieldAlias[ $i ] . "'+"; |
|
344 | + $fieldAlias[$i] = "'+" . $fieldAlias[$i] . "'+"; |
|
345 | 345 | } |
346 | 346 | } |
347 | 347 | |
@@ -493,7 +493,7 @@ discard block |
||
493 | 493 | |
494 | 494 | $this->select( |
495 | 495 | sprintf( |
496 | - $SqlScalarFunctions[ $type ], |
|
496 | + $SqlScalarFunctions[$type], |
|
497 | 497 | $field, |
498 | 498 | $this->conn->escapeIdentifiers($alias) |
499 | 499 | ) |
@@ -698,7 +698,7 @@ discard block |
||
698 | 698 | |
699 | 699 | if (is_array($field)) { |
700 | 700 | $fieldName = key($field); |
701 | - $fieldAlias = $field[ $fieldName ]; |
|
701 | + $fieldAlias = $field[$fieldName]; |
|
702 | 702 | } elseif (strpos($field, ' AS ') !== false) { |
703 | 703 | $xField = explode(' AS ', $field); |
704 | 704 | $xField = array_map('trim', $xField); |
@@ -905,7 +905,7 @@ discard block |
||
905 | 905 | public function dateDiff(array $fields, $alias) |
906 | 906 | { |
907 | 907 | $dateTimeStart = key($fields); |
908 | - $dateTimeEnd = $fields[ $dateTimeStart ]; |
|
908 | + $dateTimeEnd = $fields[$dateTimeStart]; |
|
909 | 909 | |
910 | 910 | if (preg_match("/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/", $dateTimeStart)) { |
911 | 911 | $dateTimeStart = $this->conn->escape($dateTimeStart); |
@@ -1088,14 +1088,14 @@ discard block |
||
1088 | 1088 | // Split multiple conditions |
1089 | 1089 | if (preg_match_all('/\sAND\s|\sOR\s/i', $condition, $joints, PREG_OFFSET_CAPTURE)) { |
1090 | 1090 | $conditions = []; |
1091 | - $joints = $joints[ 0 ]; |
|
1091 | + $joints = $joints[0]; |
|
1092 | 1092 | array_unshift($joints, ['', 0]); |
1093 | 1093 | |
1094 | 1094 | for ($i = count($joints) - 1, $pos = strlen($condition); $i >= 0; $i--) { |
1095 | - $joints[ $i ][ 1 ] += strlen($joints[ $i ][ 0 ]); // offset |
|
1096 | - $conditions[ $i ] = substr($condition, $joints[ $i ][ 1 ], $pos - $joints[ $i ][ 1 ]); |
|
1097 | - $pos = $joints[ $i ][ 1 ] - strlen($joints[ $i ][ 0 ]); |
|
1098 | - $joints[ $i ] = $joints[ $i ][ 0 ]; |
|
1095 | + $joints[$i][1] += strlen($joints[$i][0]); // offset |
|
1096 | + $conditions[$i] = substr($condition, $joints[$i][1], $pos - $joints[$i][1]); |
|
1097 | + $pos = $joints[$i][1] - strlen($joints[$i][0]); |
|
1098 | + $joints[$i] = $joints[$i][0]; |
|
1099 | 1099 | } |
1100 | 1100 | } else { |
1101 | 1101 | $conditions = [$condition]; |
@@ -1104,17 +1104,17 @@ discard block |
||
1104 | 1104 | |
1105 | 1105 | $condition = ' ON '; |
1106 | 1106 | for ($i = 0, $c = count($conditions); $i < $c; $i++) { |
1107 | - $operator = $this->getOperator($conditions[ $i ]); |
|
1108 | - $condition .= $joints[ $i ]; |
|
1107 | + $operator = $this->getOperator($conditions[$i]); |
|
1108 | + $condition .= $joints[$i]; |
|
1109 | 1109 | $condition .= preg_match( |
1110 | 1110 | "/(\(*)?([\[\]\w\.'-]+)" . preg_quote($operator) . "(.*)/i", |
1111 | - $conditions[ $i ], |
|
1111 | + $conditions[$i], |
|
1112 | 1112 | $match |
1113 | 1113 | ) |
1114 | - ? $match[ 1 ] . $this->conn->protectIdentifiers( |
|
1115 | - $match[ 2 ] |
|
1116 | - ) . $operator . $this->conn->protectIdentifiers($match[ 3 ]) |
|
1117 | - : $conditions[ $i ]; |
|
1114 | + ? $match[1] . $this->conn->protectIdentifiers( |
|
1115 | + $match[2] |
|
1116 | + ) . $operator . $this->conn->protectIdentifiers($match[3]) |
|
1117 | + : $conditions[$i]; |
|
1118 | 1118 | } |
1119 | 1119 | } |
1120 | 1120 | |
@@ -1178,23 +1178,23 @@ discard block |
||
1178 | 1178 | : ''; |
1179 | 1179 | |
1180 | 1180 | $operator = [ |
1181 | - '\s*(?:<|>|!)?=\s*', // =, <=, >=, != |
|
1182 | - '\s*<>?\s*', // <, <> |
|
1183 | - '\s*>\s*', // > |
|
1184 | - '\s+IS NULL', // IS NULL |
|
1185 | - '\s+IS NOT NULL', // IS NOT NULL |
|
1186 | - '\s+EXISTS\s*\(.*\)', // EXISTS(Sql) |
|
1187 | - '\s+NOT EXISTS\s*\(.*\)', // NOT EXISTS(Sql) |
|
1188 | - '\s+BETWEEN\s+', // BETWEEN value AND value |
|
1189 | - '\s+IN\s*\(.*\)', // IN(list) |
|
1190 | - '\s+NOT IN\s*\(.*\)', // NOT IN (list) |
|
1191 | - '\s+LIKE\s+\S.*(' . $likeEscapeString . ')?', // LIKE 'expr'[ ESCAPE '%s'] |
|
1181 | + '\s*(?:<|>|!)?=\s*', // =, <=, >=, != |
|
1182 | + '\s*<>?\s*', // <, <> |
|
1183 | + '\s*>\s*', // > |
|
1184 | + '\s+IS NULL', // IS NULL |
|
1185 | + '\s+IS NOT NULL', // IS NOT NULL |
|
1186 | + '\s+EXISTS\s*\(.*\)', // EXISTS(Sql) |
|
1187 | + '\s+NOT EXISTS\s*\(.*\)', // NOT EXISTS(Sql) |
|
1188 | + '\s+BETWEEN\s+', // BETWEEN value AND value |
|
1189 | + '\s+IN\s*\(.*\)', // IN(list) |
|
1190 | + '\s+NOT IN\s*\(.*\)', // NOT IN (list) |
|
1191 | + '\s+LIKE\s+\S.*(' . $likeEscapeString . ')?', // LIKE 'expr'[ ESCAPE '%s'] |
|
1192 | 1192 | '\s+NOT LIKE\s+\S.*(' . $likeEscapeString . ')?' // NOT LIKE 'expr'[ ESCAPE '%s'] |
1193 | 1193 | ]; |
1194 | 1194 | } |
1195 | 1195 | |
1196 | 1196 | return preg_match('/' . implode('|', $operator) . '/i', $string, $match) |
1197 | - ? $match[ 0 ] |
|
1197 | + ? $match[0] |
|
1198 | 1198 | : false; |
1199 | 1199 | } |
1200 | 1200 | |
@@ -1264,8 +1264,8 @@ discard block |
||
1264 | 1264 | $fieldName = substr( |
1265 | 1265 | $fieldName, |
1266 | 1266 | 0, |
1267 | - $match[ 0 ][ 1 ] |
|
1268 | - ) . ($match[ 1 ][ 0 ] === '=' |
|
1267 | + $match[0][1] |
|
1268 | + ) . ($match[1][0] === '=' |
|
1269 | 1269 | ? ' IS NULL' |
1270 | 1270 | : ' IS NOT NULL'); |
1271 | 1271 | } elseif ($fieldValue instanceof AbstractQueryBuilder) { |
@@ -1321,7 +1321,7 @@ discard block |
||
1321 | 1321 | public function bind($field, $value) |
1322 | 1322 | { |
1323 | 1323 | if ( ! array_key_exists($field, $this->builderCache->binds)) { |
1324 | - $this->builderCache->binds[ $field ] = $value; |
|
1324 | + $this->builderCache->binds[$field] = $value; |
|
1325 | 1325 | |
1326 | 1326 | return $field; |
1327 | 1327 | } |
@@ -1332,7 +1332,7 @@ discard block |
||
1332 | 1332 | ++$count; |
1333 | 1333 | } |
1334 | 1334 | |
1335 | - $this->builderCache->binds[ $field . '_' . $count ] = $value; |
|
1335 | + $this->builderCache->binds[$field . '_' . $count] = $value; |
|
1336 | 1336 | |
1337 | 1337 | return $field . '_' . $count; |
1338 | 1338 | } |
@@ -1865,8 +1865,8 @@ discard block |
||
1865 | 1865 | |
1866 | 1866 | // Do we have a seed value? |
1867 | 1867 | $fields = ctype_digit((string)$fields) |
1868 | - ? sprintf($this->SqlOrderByRandomKeywords[ 1 ], $fields) |
|
1869 | - : $this->SqlOrderByRandomKeywords[ 0 ]; |
|
1868 | + ? sprintf($this->SqlOrderByRandomKeywords[1], $fields) |
|
1869 | + : $this->SqlOrderByRandomKeywords[0]; |
|
1870 | 1870 | } elseif (empty($fields)) { |
1871 | 1871 | return $this; |
1872 | 1872 | } elseif ($direction !== '') { |
@@ -1894,8 +1894,8 @@ discard block |
||
1894 | 1894 | PREG_OFFSET_CAPTURE |
1895 | 1895 | )) |
1896 | 1896 | ? [ |
1897 | - 'field' => ltrim(substr($fields, 0, $match[ 0 ][ 1 ])), |
|
1898 | - 'direction' => ' ' . $match[ 1 ][ 0 ], |
|
1897 | + 'field' => ltrim(substr($fields, 0, $match[0][1])), |
|
1898 | + 'direction' => ' ' . $match[1][0], |
|
1899 | 1899 | 'escape' => true, |
1900 | 1900 | ] |
1901 | 1901 | : ['field' => trim($fields), 'direction' => $direction, 'escape' => true]; |
@@ -2300,7 +2300,7 @@ discard block |
||
2300 | 2300 | if (count($this->builderCache->sets)) { |
2301 | 2301 | $sqlStatement = $this->platformInsertStatement( |
2302 | 2302 | $this->conn->protectIdentifiers( |
2303 | - $this->builderCache->from[ 0 ], |
|
2303 | + $this->builderCache->from[0], |
|
2304 | 2304 | true, |
2305 | 2305 | $escape, |
2306 | 2306 | false |
@@ -2347,19 +2347,19 @@ discard block |
||
2347 | 2347 | : $this->conn->isProtectIdentifiers; |
2348 | 2348 | |
2349 | 2349 | foreach ($field as $key => $value) { |
2350 | - if($key === 'birthday' || $key === 'date') { |
|
2350 | + if ($key === 'birthday' || $key === 'date') { |
|
2351 | 2351 | if (is_array($value)) { |
2352 | 2352 | $value = $value['year'] . '-' . $value['month'] . '-' . $value['date']; |
2353 | - } elseif(is_object($value)) { |
|
2353 | + } elseif (is_object($value)) { |
|
2354 | 2354 | $value = $value->year . '-' . $value->month . '-' . $value->date; |
2355 | 2355 | } |
2356 | 2356 | } elseif (is_array($value) || is_object($value)) { |
2357 | 2357 | $value = call_user_func_array($this->arrayObjectConversionMethod, [$value]); |
2358 | 2358 | } |
2359 | 2359 | |
2360 | - $this->builderCache->binds[ $key ] = $value; |
|
2361 | - $this->builderCache->sets[ $this->conn->protectIdentifiers($key, false, |
|
2362 | - $escape) ] = ':' . $key; |
|
2360 | + $this->builderCache->binds[$key] = $value; |
|
2361 | + $this->builderCache->sets[$this->conn->protectIdentifiers($key, false, |
|
2362 | + $escape)] = ':' . $key; |
|
2363 | 2363 | } |
2364 | 2364 | |
2365 | 2365 | return $this; |
@@ -2386,7 +2386,7 @@ discard block |
||
2386 | 2386 | foreach (get_object_vars($object) as $key => $value) { |
2387 | 2387 | // There are some built in keys we need to ignore for this conversion |
2388 | 2388 | if ( ! is_object($value) && ! is_array($value) && $key !== '_parent_name') { |
2389 | - $array[ $key ] = $value; |
|
2389 | + $array[$key] = $value; |
|
2390 | 2390 | } |
2391 | 2391 | } |
2392 | 2392 | |
@@ -2432,7 +2432,7 @@ discard block |
||
2432 | 2432 | $affectedRows = 0; |
2433 | 2433 | for ($i = 0, $total = count($sets); $i < $total; $i += $batchSize) { |
2434 | 2434 | $Sql = $this->platformInsertBatchStatement( |
2435 | - $this->conn->protectIdentifiers($this->builderCache->from[ 0 ], true, $escape, false), |
|
2435 | + $this->conn->protectIdentifiers($this->builderCache->from[0], true, $escape, false), |
|
2436 | 2436 | $this->builderCache->keys, |
2437 | 2437 | array_slice($this->builderCache->sets, $i, $batchSize) |
2438 | 2438 | ); |
@@ -2533,8 +2533,8 @@ discard block |
||
2533 | 2533 | // There are some built in keys we need to ignore for this conversion |
2534 | 2534 | if ($field !== '_parent_name') { |
2535 | 2535 | $i = 0; |
2536 | - foreach ($out[ $field ] as $data) { |
|
2537 | - $array[ $i++ ][ $field ] = $data; |
|
2536 | + foreach ($out[$field] as $data) { |
|
2537 | + $array[$i++][$field] = $data; |
|
2538 | 2538 | } |
2539 | 2539 | } |
2540 | 2540 | } |
@@ -2583,7 +2583,7 @@ discard block |
||
2583 | 2583 | if (count($this->builderCache->sets)) { |
2584 | 2584 | $sqlStatement = $this->platformReplaceStatement( |
2585 | 2585 | $this->conn->protectIdentifiers( |
2586 | - $this->builderCache->from[ 0 ], |
|
2586 | + $this->builderCache->from[0], |
|
2587 | 2587 | true, |
2588 | 2588 | $escape, |
2589 | 2589 | false |
@@ -2644,7 +2644,7 @@ discard block |
||
2644 | 2644 | $affectedRows = 0; |
2645 | 2645 | for ($i = 0, $total = count($sets); $i < $total; $i += $batchSize) { |
2646 | 2646 | $Sql = $this->platformReplaceStatement( |
2647 | - $this->conn->protectIdentifiers($this->builderCache->from[ 0 ], true, $escape, false), |
|
2647 | + $this->conn->protectIdentifiers($this->builderCache->from[0], true, $escape, false), |
|
2648 | 2648 | $this->builderCache->keys, |
2649 | 2649 | array_slice($this->builderCache->sets, $i, $batchSize) |
2650 | 2650 | ); |
@@ -2694,7 +2694,7 @@ discard block |
||
2694 | 2694 | if (count($this->builderCache->sets) && count($this->builderCache->from)) { |
2695 | 2695 | $sqlStatement = $this->platformUpdateStatement( |
2696 | 2696 | $this->conn->protectIdentifiers( |
2697 | - $this->builderCache->from[ 0 ], |
|
2697 | + $this->builderCache->from[0], |
|
2698 | 2698 | true, |
2699 | 2699 | $escape, |
2700 | 2700 | false |
@@ -2753,7 +2753,7 @@ discard block |
||
2753 | 2753 | $affectedRows = 0; |
2754 | 2754 | for ($i = 0, $total = count($this->builderCache->sets); $i < $total; $i += $batchSize) { |
2755 | 2755 | $Sql = $this->platformUpdateBatchStatement( |
2756 | - $this->builderCache->from[ 0 ], |
|
2756 | + $this->builderCache->from[0], |
|
2757 | 2757 | array_slice($this->builderCache->sets, $i, $batchSize), |
2758 | 2758 | $this->conn->protectIdentifiers($index, false, $escape, false) |
2759 | 2759 | ); |
@@ -2765,7 +2765,7 @@ discard block |
||
2765 | 2765 | $affectedRows += $this->conn->getAffectedRows(); |
2766 | 2766 | } |
2767 | 2767 | |
2768 | - $this->builderCache[ 'where' ] = []; |
|
2768 | + $this->builderCache['where'] = []; |
|
2769 | 2769 | } |
2770 | 2770 | |
2771 | 2771 | if ( ! $this->testMode) { |
@@ -2809,7 +2809,7 @@ discard block |
||
2809 | 2809 | |
2810 | 2810 | $bind = $this->bind($key, $value); |
2811 | 2811 | |
2812 | - $cleanSets[ $this->conn->protectIdentifiers($key, false, $escape) ] = ':' . $bind; |
|
2812 | + $cleanSets[$this->conn->protectIdentifiers($key, false, $escape)] = ':' . $bind; |
|
2813 | 2813 | } |
2814 | 2814 | |
2815 | 2815 | if ($indexSet === false) { |
@@ -2859,7 +2859,7 @@ discard block |
||
2859 | 2859 | |
2860 | 2860 | $sqlStatement = $this->platformDeleteStatement( |
2861 | 2861 | $this->conn->protectIdentifiers( |
2862 | - $this->builderCache->from[ 0 ], |
|
2862 | + $this->builderCache->from[0], |
|
2863 | 2863 | true, |
2864 | 2864 | $this->conn->isProtectIdentifiers, |
2865 | 2865 | false |
@@ -3036,10 +3036,10 @@ discard block |
||
3036 | 3036 | // The reason we protect identifiers here rather than in the select() function |
3037 | 3037 | // is because until the user calls the from() function we don't know if there are aliases |
3038 | 3038 | foreach ($this->builderCache->select as $selectKey => $selectField) { |
3039 | - $noEscape = isset($this->builderCache->noEscape [ $selectKey ]) |
|
3040 | - ? $this->builderCache->noEscape [ $selectKey ] |
|
3039 | + $noEscape = isset($this->builderCache->noEscape [$selectKey]) |
|
3040 | + ? $this->builderCache->noEscape [$selectKey] |
|
3041 | 3041 | : null; |
3042 | - $this->builderCache->select [ $selectKey ] = $this->conn->protectIdentifiers( |
|
3042 | + $this->builderCache->select [$selectKey] = $this->conn->protectIdentifiers( |
|
3043 | 3043 | $selectField, |
3044 | 3044 | false, |
3045 | 3045 | $noEscape |
@@ -3158,28 +3158,28 @@ discard block |
||
3158 | 3158 | if (count($this->builderCache->{$cacheKey}) > 0) { |
3159 | 3159 | for ($i = 0, $c = count($this->builderCache->{$cacheKey}); $i < $c; $i++) { |
3160 | 3160 | // Is this condition already compiled? |
3161 | - if (is_string($this->builderCache->{$cacheKey}[ $i ])) { |
|
3161 | + if (is_string($this->builderCache->{$cacheKey}[$i])) { |
|
3162 | 3162 | continue; |
3163 | - } elseif ($this->builderCache->{$cacheKey}[ $i ][ 'escape' ] === false) { |
|
3164 | - $this->builderCache->{$cacheKey}[ $i ] |
|
3165 | - = $this->builderCache->{$cacheKey}[ $i ][ 'condition' ]; |
|
3163 | + } elseif ($this->builderCache->{$cacheKey}[$i]['escape'] === false) { |
|
3164 | + $this->builderCache->{$cacheKey}[$i] |
|
3165 | + = $this->builderCache->{$cacheKey}[$i]['condition']; |
|
3166 | 3166 | continue; |
3167 | 3167 | } |
3168 | 3168 | |
3169 | 3169 | // Split multiple conditions |
3170 | 3170 | $conditions = preg_split( |
3171 | 3171 | '/((?:^|\s+)AND\s+|(?:^|\s+)OR\s+)/i', |
3172 | - $this->builderCache->{$cacheKey}[ $i ][ 'condition' ], |
|
3172 | + $this->builderCache->{$cacheKey}[$i]['condition'], |
|
3173 | 3173 | -1, |
3174 | 3174 | PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY |
3175 | 3175 | ); |
3176 | 3176 | |
3177 | 3177 | for ($ci = 0, $cc = count($conditions); $ci < $cc; $ci++) { |
3178 | - if (($op = $this->getOperator($conditions[ $ci ])) === false |
|
3178 | + if (($op = $this->getOperator($conditions[$ci])) === false |
|
3179 | 3179 | OR |
3180 | 3180 | ! preg_match( |
3181 | 3181 | '/^(\(?)(.*)(' . preg_quote($op, '/') . ')\s*(.*(?<!\)))?(\)?)$/i', |
3182 | - $conditions[ $ci ], |
|
3182 | + $conditions[$ci], |
|
3183 | 3183 | $matches |
3184 | 3184 | ) |
3185 | 3185 | ) { |
@@ -3195,16 +3195,16 @@ discard block |
||
3195 | 3195 | // 5 => ')' /* optional */ |
3196 | 3196 | // ); |
3197 | 3197 | |
3198 | - if ( ! empty($matches[ 4 ])) { |
|
3198 | + if ( ! empty($matches[4])) { |
|
3199 | 3199 | //$this->isLiteral($matches[4]) OR $matches[4] = $this->protectIdentifiers(trim($matches[4])); |
3200 | - $matches[ 4 ] = ' ' . $matches[ 4 ]; |
|
3200 | + $matches[4] = ' ' . $matches[4]; |
|
3201 | 3201 | } |
3202 | 3202 | |
3203 | - $conditions[ $ci ] = $matches[ 1 ] . $this->conn->protectIdentifiers(trim($matches[ 2 ])) |
|
3204 | - . ' ' . trim($matches[ 3 ]) . $matches[ 4 ] . $matches[ 5 ]; |
|
3203 | + $conditions[$ci] = $matches[1] . $this->conn->protectIdentifiers(trim($matches[2])) |
|
3204 | + . ' ' . trim($matches[3]) . $matches[4] . $matches[5]; |
|
3205 | 3205 | } |
3206 | 3206 | |
3207 | - $this->builderCache->{$cacheKey}[ $i ] = implode('', $conditions); |
|
3207 | + $this->builderCache->{$cacheKey}[$i] = implode('', $conditions); |
|
3208 | 3208 | } |
3209 | 3209 | |
3210 | 3210 | if ($cacheKey === 'having') { |
@@ -3243,17 +3243,17 @@ discard block |
||
3243 | 3243 | if (count($this->builderCache->groupBy) > 0) { |
3244 | 3244 | for ($i = 0, $c = count($this->builderCache->groupBy); $i < $c; $i++) { |
3245 | 3245 | // Is it already compiled? |
3246 | - if (is_string($this->builderCache->groupBy[ $i ])) { |
|
3246 | + if (is_string($this->builderCache->groupBy[$i])) { |
|
3247 | 3247 | continue; |
3248 | 3248 | } |
3249 | 3249 | |
3250 | - $this->builderCache->groupBy[ $i ] = ($this->builderCache->groupBy[ $i ][ 'escape' ] |
|
3250 | + $this->builderCache->groupBy[$i] = ($this->builderCache->groupBy[$i]['escape'] |
|
3251 | 3251 | === false OR |
3252 | 3252 | $this->isLiteral( |
3253 | - $this->builderCache->groupBy[ $i ][ 'field' ] |
|
3253 | + $this->builderCache->groupBy[$i]['field'] |
|
3254 | 3254 | )) |
3255 | - ? $this->builderCache->groupBy[ $i ][ 'field' ] |
|
3256 | - : $this->conn->protectIdentifiers($this->builderCache->groupBy[ $i ][ 'field' ]); |
|
3255 | + ? $this->builderCache->groupBy[$i]['field'] |
|
3256 | + : $this->conn->protectIdentifiers($this->builderCache->groupBy[$i]['field']); |
|
3257 | 3257 | } |
3258 | 3258 | |
3259 | 3259 | return "\n" . sprintf( |
@@ -3298,7 +3298,7 @@ discard block |
||
3298 | 3298 | : ["'"]; |
3299 | 3299 | } |
3300 | 3300 | |
3301 | - return in_array($string[ 0 ], $stringArray, true); |
|
3301 | + return in_array($string[0], $stringArray, true); |
|
3302 | 3302 | } |
3303 | 3303 | |
3304 | 3304 | //-------------------------------------------------------------------- |
@@ -3356,18 +3356,18 @@ discard block |
||
3356 | 3356 | { |
3357 | 3357 | if (is_array($this->builderCache->orderBy) && count($this->builderCache->orderBy) > 0) { |
3358 | 3358 | for ($i = 0, $c = count($this->builderCache->orderBy); $i < $c; $i++) { |
3359 | - if ($this->builderCache->orderBy[ $i ][ 'escape' ] !== false |
|
3359 | + if ($this->builderCache->orderBy[$i]['escape'] !== false |
|
3360 | 3360 | && ! $this->isLiteral( |
3361 | - $this->builderCache->orderBy[ $i ][ 'field' ] |
|
3361 | + $this->builderCache->orderBy[$i]['field'] |
|
3362 | 3362 | ) |
3363 | 3363 | ) { |
3364 | - $this->builderCache->orderBy[ $i ][ 'field' ] = $this->conn->protectIdentifiers( |
|
3365 | - $this->builderCache->orderBy[ $i ][ 'field' ] |
|
3364 | + $this->builderCache->orderBy[$i]['field'] = $this->conn->protectIdentifiers( |
|
3365 | + $this->builderCache->orderBy[$i]['field'] |
|
3366 | 3366 | ); |
3367 | 3367 | } |
3368 | 3368 | |
3369 | - $this->builderCache->orderBy[ $i ] = $this->builderCache->orderBy[ $i ][ 'field' ] |
|
3370 | - . $this->builderCache->orderBy[ $i ][ 'direction' ]; |
|
3369 | + $this->builderCache->orderBy[$i] = $this->builderCache->orderBy[$i]['field'] |
|
3370 | + . $this->builderCache->orderBy[$i]['direction']; |
|
3371 | 3371 | } |
3372 | 3372 | |
3373 | 3373 | return $this->builderCache->orderBy = "\n" . sprintf( |
@@ -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 | //-------------------------------------------------------------------- |
@@ -527,11 +527,11 @@ discard block |
||
527 | 527 | */ |
528 | 528 | final public function hasDatabase($databaseName) |
529 | 529 | { |
530 | - if (empty($this->queriesResultCache[ 'databaseNames' ])) { |
|
530 | + if (empty($this->queriesResultCache['databaseNames'])) { |
|
531 | 531 | $this->getDatabases(); |
532 | 532 | } |
533 | 533 | |
534 | - return (bool)in_array($databaseName, $this->queriesResultCache[ 'databaseNames' ]); |
|
534 | + return (bool)in_array($databaseName, $this->queriesResultCache['databaseNames']); |
|
535 | 535 | } |
536 | 536 | |
537 | 537 | //-------------------------------------------------------------------- |
@@ -557,7 +557,7 @@ discard block |
||
557 | 557 | */ |
558 | 558 | final public function setTablePrefix($tablePrefix) |
559 | 559 | { |
560 | - return $this->config[ 'tablePrefix' ] = $tablePrefix; |
|
560 | + return $this->config['tablePrefix'] = $tablePrefix; |
|
561 | 561 | } |
562 | 562 | |
563 | 563 | // ------------------------------------------------------------------------ |
@@ -575,11 +575,11 @@ discard block |
||
575 | 575 | { |
576 | 576 | $table = $this->prefixTable($table); |
577 | 577 | |
578 | - if (empty($this->queriesResultCache[ 'tableNames' ])) { |
|
578 | + if (empty($this->queriesResultCache['tableNames'])) { |
|
579 | 579 | $this->getTables(); |
580 | 580 | } |
581 | 581 | |
582 | - return (bool)in_array($table, $this->queriesResultCache[ 'tableNames' ]); |
|
582 | + return (bool)in_array($table, $this->queriesResultCache['tableNames']); |
|
583 | 583 | } |
584 | 584 | |
585 | 585 | // ------------------------------------------------------------------------ |
@@ -593,7 +593,7 @@ discard block |
||
593 | 593 | */ |
594 | 594 | final public function prefixTable($tableName) |
595 | 595 | { |
596 | - $tablePrefix = $this->config[ 'tablePrefix' ]; |
|
596 | + $tablePrefix = $this->config['tablePrefix']; |
|
597 | 597 | |
598 | 598 | if (empty($tablePrefix)) { |
599 | 599 | return $tableName; |
@@ -632,11 +632,11 @@ discard block |
||
632 | 632 | { |
633 | 633 | $table = $this->prefixTable($table); |
634 | 634 | |
635 | - if (empty($this->queriesResultCache[ 'tableColumns' ][ $table ])) { |
|
635 | + if (empty($this->queriesResultCache['tableColumns'][$table])) { |
|
636 | 636 | $this->getColumns($table); |
637 | 637 | } |
638 | 638 | |
639 | - return (bool)isset($this->queriesResultCache[ 'tableColumns' ][ $table ][ $column ]); |
|
639 | + return (bool)isset($this->queriesResultCache['tableColumns'][$table][$column]); |
|
640 | 640 | } |
641 | 641 | |
642 | 642 | // ------------------------------------------------------------------------ |
@@ -681,7 +681,7 @@ discard block |
||
681 | 681 | $queryStatement->setLastInsertId($this->getLastInsertId()); |
682 | 682 | |
683 | 683 | if ( ! array_key_exists($queryStatement->getKey(), $this->queriesCache)) { |
684 | - $this->queriesCache[ $queryStatement->getKey() ] = $queryStatement; |
|
684 | + $this->queriesCache[$queryStatement->getKey()] = $queryStatement; |
|
685 | 685 | } |
686 | 686 | |
687 | 687 | if ($queryStatement->hasError()) { |
@@ -818,7 +818,7 @@ discard block |
||
818 | 818 | $queryStatement->addHit(1); |
819 | 819 | |
820 | 820 | if ( ! array_key_exists($queryStatement->getKey(), $this->queriesCache)) { |
821 | - $this->queriesCache[ $queryStatement->getKey() ] = $queryStatement; |
|
821 | + $this->queriesCache[$queryStatement->getKey()] = $queryStatement; |
|
822 | 822 | } |
823 | 823 | |
824 | 824 | if ($queryStatement->hasError()) { |
@@ -858,8 +858,8 @@ discard block |
||
858 | 858 | { |
859 | 859 | $hasSqlBinders = strpos($sqlStatement, ':') !== false; |
860 | 860 | |
861 | - if (empty($binds) || empty($this->config[ 'bindMarker' ]) || |
|
862 | - (strpos($sqlStatement, $this->config[ 'bindMarker' ]) === false && |
|
861 | + if (empty($binds) || empty($this->config['bindMarker']) || |
|
862 | + (strpos($sqlStatement, $this->config['bindMarker']) === false && |
|
863 | 863 | $hasSqlBinders === false) |
864 | 864 | ) { |
865 | 865 | return $sqlStatement; |
@@ -880,7 +880,7 @@ discard block |
||
880 | 880 | } |
881 | 881 | |
882 | 882 | // We'll need marker length later |
883 | - $markerLength = strlen($this->config[ 'bindMarker' ]); |
|
883 | + $markerLength = strlen($this->config['bindMarker']); |
|
884 | 884 | |
885 | 885 | if ($hasSqlBinders) { |
886 | 886 | $sqlStatement = $this->replaceNamedBinds($sqlStatement, $sqlBinds); |
@@ -920,7 +920,7 @@ discard block |
||
920 | 920 | } elseif (strpos($bindReplace, ' AND ') !== false) { |
921 | 921 | $escapedValue = $bindReplace; |
922 | 922 | } else { |
923 | - $escapedValue = preg_quote(trim($escapedValue, $this->config[ 'escapeCharacter' ])); |
|
923 | + $escapedValue = preg_quote(trim($escapedValue, $this->config['escapeCharacter'])); |
|
924 | 924 | } |
925 | 925 | |
926 | 926 | if (preg_match("/\(.+?\)/", $bindSearch)) { |
@@ -985,7 +985,7 @@ discard block |
||
985 | 985 | { |
986 | 986 | if (is_array($string)) { |
987 | 987 | foreach ($string as $key => $value) { |
988 | - $string[ $key ] = $this->escapeString($value, $like); |
|
988 | + $string[$key] = $this->escapeString($value, $like); |
|
989 | 989 | } |
990 | 990 | |
991 | 991 | return $string; |
@@ -996,11 +996,11 @@ discard block |
||
996 | 996 | // escape LIKE condition wildcards |
997 | 997 | if ($like === true) { |
998 | 998 | $string = str_replace( |
999 | - [$this->config[ 'likeEscapeCharacter' ], '%', '_'], |
|
999 | + [$this->config['likeEscapeCharacter'], '%', '_'], |
|
1000 | 1000 | [ |
1001 | - $this->config[ 'likeEscapeCharacter' ] . $this->config[ 'likeEscapeCharacter' ], |
|
1002 | - $this->config[ 'likeEscapeCharacter' ] . '%', |
|
1003 | - $this->config[ 'likeEscapeCharacter' ] . '_', |
|
1001 | + $this->config['likeEscapeCharacter'] . $this->config['likeEscapeCharacter'], |
|
1002 | + $this->config['likeEscapeCharacter'] . '%', |
|
1003 | + $this->config['likeEscapeCharacter'] . '_', |
|
1004 | 1004 | ], |
1005 | 1005 | $string |
1006 | 1006 | ); |
@@ -1045,10 +1045,10 @@ discard block |
||
1045 | 1045 | // Make sure not to replace a chunk inside a string that happens to match the bind marker |
1046 | 1046 | if ($chunk = preg_match_all("/'[^']*'/i", $sqlStatement, $matches)) { |
1047 | 1047 | $chunk = preg_match_all( |
1048 | - '/' . preg_quote($this->config[ 'bindMarker' ], '/') . '/i', |
|
1048 | + '/' . preg_quote($this->config['bindMarker'], '/') . '/i', |
|
1049 | 1049 | str_replace( |
1050 | - $matches[ 0 ], |
|
1051 | - str_replace($this->config[ 'bindMarker' ], str_repeat(' ', $markerLength), $matches[ 0 ]), |
|
1050 | + $matches[0], |
|
1051 | + str_replace($this->config['bindMarker'], str_repeat(' ', $markerLength), $matches[0]), |
|
1052 | 1052 | $sqlStatement, |
1053 | 1053 | $chunk |
1054 | 1054 | ), |
@@ -1063,7 +1063,7 @@ discard block |
||
1063 | 1063 | } // Number of binds must match bindMarkers in the string. |
1064 | 1064 | else { |
1065 | 1065 | if (($chunk = preg_match_all( |
1066 | - '/' . preg_quote($this->config[ 'bindMarker' ], '/') . '/i', |
|
1066 | + '/' . preg_quote($this->config['bindMarker'], '/') . '/i', |
|
1067 | 1067 | $sqlStatement, |
1068 | 1068 | $matches, |
1069 | 1069 | PREG_OFFSET_CAPTURE |
@@ -1075,11 +1075,11 @@ discard block |
||
1075 | 1075 | |
1076 | 1076 | do { |
1077 | 1077 | $chunk--; |
1078 | - $escapedValue = $this->escape($sqlBinds[ $chunk ]); |
|
1078 | + $escapedValue = $this->escape($sqlBinds[$chunk]); |
|
1079 | 1079 | if (is_array($escapedValue)) { |
1080 | 1080 | $escapedValue = '(' . implode(',', $escapedValue) . ')'; |
1081 | 1081 | } |
1082 | - $sqlStatement = substr_replace($sqlStatement, $escapedValue, $matches[ 0 ][ $chunk ][ 1 ], $markerLength); |
|
1082 | + $sqlStatement = substr_replace($sqlStatement, $escapedValue, $matches[0][$chunk][1], $markerLength); |
|
1083 | 1083 | } while ($chunk !== 0); |
1084 | 1084 | |
1085 | 1085 | return $sqlStatement; |
@@ -1292,7 +1292,7 @@ discard block |
||
1292 | 1292 | if (is_array($item)) { |
1293 | 1293 | $escapedArray = []; |
1294 | 1294 | foreach ($item as $key => $value) { |
1295 | - $escapedArray[ $this->protectIdentifiers($key) ] = $this->protectIdentifiers( |
|
1295 | + $escapedArray[$this->protectIdentifiers($key)] = $this->protectIdentifiers( |
|
1296 | 1296 | $value, |
1297 | 1297 | $prefixSingle, |
1298 | 1298 | $protectIdentifiers, |
@@ -1350,11 +1350,11 @@ discard block |
||
1350 | 1350 | // |
1351 | 1351 | // NOTE: The ! empty() condition prevents this method |
1352 | 1352 | // from breaking when Query Builder isn't enabled. |
1353 | - if ( ! empty($aliasedTables) AND in_array($parts[ 0 ], $aliasedTables)) { |
|
1353 | + if ( ! empty($aliasedTables) AND in_array($parts[0], $aliasedTables)) { |
|
1354 | 1354 | if ($protectIdentifiers === true) { |
1355 | 1355 | foreach ($parts as $key => $val) { |
1356 | - if ( ! in_array($val, $this->config[ 'reservedIdentifiers' ])) { |
|
1357 | - $parts[ $key ] = $this->escapeIdentifiers($val); |
|
1356 | + if ( ! in_array($val, $this->config['reservedIdentifiers'])) { |
|
1357 | + $parts[$key] = $this->escapeIdentifiers($val); |
|
1358 | 1358 | } |
1359 | 1359 | } |
1360 | 1360 | |
@@ -1369,12 +1369,12 @@ discard block |
||
1369 | 1369 | // We now add the table prefix based on some logic. |
1370 | 1370 | // Do we have 4 segments (hostname.database.table.column)? |
1371 | 1371 | // If so, we add the table prefix to the column name in the 3rd segment. |
1372 | - if (isset($parts[ 3 ])) { |
|
1372 | + if (isset($parts[3])) { |
|
1373 | 1373 | $i = 2; |
1374 | 1374 | } |
1375 | 1375 | // Do we have 3 segments (database.table.column)? |
1376 | 1376 | // If so, we add the table prefix to the column name in 2nd position |
1377 | - elseif (isset($parts[ 2 ])) { |
|
1377 | + elseif (isset($parts[2])) { |
|
1378 | 1378 | $i = 1; |
1379 | 1379 | } |
1380 | 1380 | // Do we have 2 segments (table.column)? |
@@ -1390,15 +1390,15 @@ discard block |
||
1390 | 1390 | } |
1391 | 1391 | |
1392 | 1392 | // Verify table prefix and replace if necessary |
1393 | - if ($this->swapTablePrefix !== '' && strpos($parts[ $i ], $this->swapTablePrefix) === 0) { |
|
1394 | - $parts[ $i ] = preg_replace( |
|
1393 | + if ($this->swapTablePrefix !== '' && strpos($parts[$i], $this->swapTablePrefix) === 0) { |
|
1394 | + $parts[$i] = preg_replace( |
|
1395 | 1395 | '/^' . $this->swapTablePrefix . '(\S+?)/', |
1396 | 1396 | $this->config->tablePrefix . '\\1', |
1397 | - $parts[ $i ] |
|
1397 | + $parts[$i] |
|
1398 | 1398 | ); |
1399 | 1399 | } // We only add the table prefix if it does not already exist |
1400 | - elseif (strpos($parts[ $i ], $this->config->tablePrefix) !== 0) { |
|
1401 | - $parts[ $i ] = $this->config->tablePrefix . $parts[ $i ]; |
|
1400 | + elseif (strpos($parts[$i], $this->config->tablePrefix) !== 0) { |
|
1401 | + $parts[$i] = $this->config->tablePrefix . $parts[$i]; |
|
1402 | 1402 | } |
1403 | 1403 | |
1404 | 1404 | // Put the parts back together |
@@ -1415,7 +1415,7 @@ discard block |
||
1415 | 1415 | // In some cases, especially 'from', we end up running through |
1416 | 1416 | // protect_identifiers twice. This algorithm won't work when |
1417 | 1417 | // it contains the escapeChar so strip it out. |
1418 | - $item = trim($item, $this->config[ 'escapeCharacter' ]); |
|
1418 | + $item = trim($item, $this->config['escapeCharacter']); |
|
1419 | 1419 | |
1420 | 1420 | // Is there a table prefix? If not, no need to insert it |
1421 | 1421 | if ($this->config->tablePrefix !== '') { |
@@ -1432,7 +1432,7 @@ discard block |
||
1432 | 1432 | } |
1433 | 1433 | } |
1434 | 1434 | |
1435 | - if ($protectIdentifiers === true && ! in_array($item, $this->config[ 'reservedIdentifiers' ])) { |
|
1435 | + if ($protectIdentifiers === true && ! in_array($item, $this->config['reservedIdentifiers'])) { |
|
1436 | 1436 | $item = $this->escapeIdentifiers($item); |
1437 | 1437 | } |
1438 | 1438 | |
@@ -1454,22 +1454,22 @@ discard block |
||
1454 | 1454 | */ |
1455 | 1455 | final public function escapeIdentifiers($item) |
1456 | 1456 | { |
1457 | - if ($this->config[ 'escapeCharacter' ] === '' OR empty($item) OR in_array( |
|
1457 | + if ($this->config['escapeCharacter'] === '' OR empty($item) OR in_array( |
|
1458 | 1458 | $item, |
1459 | - $this->config[ 'reservedIdentifiers' ] |
|
1459 | + $this->config['reservedIdentifiers'] |
|
1460 | 1460 | ) |
1461 | 1461 | ) { |
1462 | 1462 | return $item; |
1463 | 1463 | } elseif (is_array($item)) { |
1464 | 1464 | foreach ($item as $key => $value) { |
1465 | - $item[ $key ] = $this->escapeIdentifiers($value); |
|
1465 | + $item[$key] = $this->escapeIdentifiers($value); |
|
1466 | 1466 | } |
1467 | 1467 | |
1468 | 1468 | return $item; |
1469 | 1469 | } // Avoid breaking functions and literal values inside queries |
1470 | 1470 | elseif (ctype_digit( |
1471 | 1471 | $item |
1472 | - ) OR $item[ 0 ] === "'" OR ($this->config[ 'escapeCharacter' ] !== '"' && $item[ 0 ] === '"') OR |
|
1472 | + ) OR $item[0] === "'" OR ($this->config['escapeCharacter'] !== '"' && $item[0] === '"') OR |
|
1473 | 1473 | strpos($item, '(') !== false |
1474 | 1474 | ) { |
1475 | 1475 | return $item; |
@@ -1478,31 +1478,31 @@ discard block |
||
1478 | 1478 | static $pregEscapeCharacters = []; |
1479 | 1479 | |
1480 | 1480 | if (empty($pregEscapeCharacters)) { |
1481 | - if (is_array($this->config[ 'escapeCharacter' ])) { |
|
1481 | + if (is_array($this->config['escapeCharacter'])) { |
|
1482 | 1482 | $pregEscapeCharacters = [ |
1483 | - preg_quote($this->config[ 'escapeCharacter' ][ 0 ], '/'), |
|
1484 | - preg_quote($this->config[ 'escapeCharacter' ][ 1 ], '/'), |
|
1485 | - $this->config[ 'escapeCharacter' ][ 0 ], |
|
1486 | - $this->config[ 'escapeCharacter' ][ 1 ], |
|
1483 | + preg_quote($this->config['escapeCharacter'][0], '/'), |
|
1484 | + preg_quote($this->config['escapeCharacter'][1], '/'), |
|
1485 | + $this->config['escapeCharacter'][0], |
|
1486 | + $this->config['escapeCharacter'][1], |
|
1487 | 1487 | ]; |
1488 | 1488 | } else { |
1489 | - $pregEscapeCharacters[ 0 ] |
|
1490 | - = $pregEscapeCharacters[ 1 ] = preg_quote($this->config[ 'escapeCharacter' ], '/'); |
|
1491 | - $pregEscapeCharacters[ 2 ] = $pregEscapeCharacters[ 3 ] = $this->config[ 'escapeCharacter' ]; |
|
1489 | + $pregEscapeCharacters[0] |
|
1490 | + = $pregEscapeCharacters[1] = preg_quote($this->config['escapeCharacter'], '/'); |
|
1491 | + $pregEscapeCharacters[2] = $pregEscapeCharacters[3] = $this->config['escapeCharacter']; |
|
1492 | 1492 | } |
1493 | 1493 | } |
1494 | 1494 | |
1495 | - foreach ($this->config[ 'reservedIdentifiers' ] as $id) { |
|
1495 | + foreach ($this->config['reservedIdentifiers'] as $id) { |
|
1496 | 1496 | if (strpos($item, '.' . $id) !== false) { |
1497 | 1497 | return preg_replace( |
1498 | 1498 | '/' |
1499 | - . $pregEscapeCharacters[ 0 ] |
|
1499 | + . $pregEscapeCharacters[0] |
|
1500 | 1500 | . '?([^' |
1501 | - . $pregEscapeCharacters[ 1 ] |
|
1501 | + . $pregEscapeCharacters[1] |
|
1502 | 1502 | . '\.]+)' |
1503 | - . $pregEscapeCharacters[ 1 ] |
|
1503 | + . $pregEscapeCharacters[1] |
|
1504 | 1504 | . '?\./i', |
1505 | - $pregEscapeCharacters[ 2 ] . '$1' . $pregEscapeCharacters[ 3 ] . '.', |
|
1505 | + $pregEscapeCharacters[2] . '$1' . $pregEscapeCharacters[3] . '.', |
|
1506 | 1506 | $item |
1507 | 1507 | ); |
1508 | 1508 | } |
@@ -1510,13 +1510,13 @@ discard block |
||
1510 | 1510 | |
1511 | 1511 | return preg_replace( |
1512 | 1512 | '/' |
1513 | - . $pregEscapeCharacters[ 0 ] |
|
1513 | + . $pregEscapeCharacters[0] |
|
1514 | 1514 | . '?([^' |
1515 | - . $pregEscapeCharacters[ 1 ] |
|
1515 | + . $pregEscapeCharacters[1] |
|
1516 | 1516 | . '\.]+)' |
1517 | - . $pregEscapeCharacters[ 1 ] |
|
1517 | + . $pregEscapeCharacters[1] |
|
1518 | 1518 | . '?(\.)?/i', |
1519 | - $pregEscapeCharacters[ 2 ] . '$1' . $pregEscapeCharacters[ 3 ] . '$2', |
|
1519 | + $pregEscapeCharacters[2] . '$1' . $pregEscapeCharacters[3] . '$2', |
|
1520 | 1520 | $item |
1521 | 1521 | ); |
1522 | 1522 | } |
@@ -124,18 +124,18 @@ discard block |
||
124 | 124 | */ |
125 | 125 | public function getDatabases() |
126 | 126 | { |
127 | - if (empty($this->queriesResultCache[ 'databaseNames' ])) { |
|
127 | + if (empty($this->queriesResultCache['databaseNames'])) { |
|
128 | 128 | $result = $this->query('SHOW DATABASES'); |
129 | 129 | |
130 | 130 | if ($result->count()) { |
131 | 131 | foreach ($result as $row) { |
132 | 132 | |
133 | 133 | if ( ! isset($key)) { |
134 | - if (isset($row[ 'database' ])) { |
|
134 | + if (isset($row['database'])) { |
|
135 | 135 | $key = 'database'; |
136 | - } elseif (isset($row[ 'Database' ])) { |
|
136 | + } elseif (isset($row['Database'])) { |
|
137 | 137 | $key = 'Database'; |
138 | - } elseif (isset($row[ 'DATABASE' ])) { |
|
138 | + } elseif (isset($row['DATABASE'])) { |
|
139 | 139 | $key = 'DATABASE'; |
140 | 140 | } else { |
141 | 141 | /* We have no other choice but to just get the first element's key. |
@@ -148,12 +148,12 @@ discard block |
||
148 | 148 | } |
149 | 149 | } |
150 | 150 | |
151 | - $this->queriesResultCache[ 'databaseNames' ][] = $row->offsetGet($key); |
|
151 | + $this->queriesResultCache['databaseNames'][] = $row->offsetGet($key); |
|
152 | 152 | } |
153 | 153 | } |
154 | 154 | } |
155 | 155 | |
156 | - return $this->queriesResultCache[ 'databaseNames' ]; |
|
156 | + return $this->queriesResultCache['databaseNames']; |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | // ------------------------------------------------------------------------ |
@@ -170,12 +170,12 @@ discard block |
||
170 | 170 | */ |
171 | 171 | public function getTables($prefixLimit = false) |
172 | 172 | { |
173 | - if (empty($this->queriesResultCache[ 'tableNames' ])) { |
|
173 | + if (empty($this->queriesResultCache['tableNames'])) { |
|
174 | 174 | |
175 | - $sqlStatement = 'SHOW TABLES FROM ' . $this->escapeIdentifiers($this->config[ 'database' ]); |
|
175 | + $sqlStatement = 'SHOW TABLES FROM ' . $this->escapeIdentifiers($this->config['database']); |
|
176 | 176 | |
177 | - if ($prefixLimit !== false && $this->config[ 'tablePrefix' ] !== '') { |
|
178 | - $sqlStatement .= " LIKE '" . $this->escapeLikeString($this->config[ 'tablePrefix' ]) . "%'"; |
|
177 | + if ($prefixLimit !== false && $this->config['tablePrefix'] !== '') { |
|
178 | + $sqlStatement .= " LIKE '" . $this->escapeLikeString($this->config['tablePrefix']) . "%'"; |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | $result = $this->query($sqlStatement); |
@@ -184,9 +184,9 @@ discard block |
||
184 | 184 | foreach ($result as $row) { |
185 | 185 | // Do we know from which column to get the table name? |
186 | 186 | if ( ! isset($key)) { |
187 | - if (isset($row[ 'table_name' ])) { |
|
187 | + if (isset($row['table_name'])) { |
|
188 | 188 | $key = 'table_name'; |
189 | - } elseif (isset($row[ 'TABLE_NAME' ])) { |
|
189 | + } elseif (isset($row['TABLE_NAME'])) { |
|
190 | 190 | $key = 'TABLE_NAME'; |
191 | 191 | } else { |
192 | 192 | /* We have no other choice but to just get the first element's key. |
@@ -199,12 +199,12 @@ discard block |
||
199 | 199 | } |
200 | 200 | } |
201 | 201 | |
202 | - $this->queriesResultCache[ 'tableNames' ][] = $row->offsetGet($key); |
|
202 | + $this->queriesResultCache['tableNames'][] = $row->offsetGet($key); |
|
203 | 203 | } |
204 | 204 | } |
205 | 205 | } |
206 | 206 | |
207 | - return $this->queriesResultCache[ 'tableNames' ]; |
|
207 | + return $this->queriesResultCache['tableNames']; |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | // ------------------------------------------------------------------------ |
@@ -221,16 +221,16 @@ discard block |
||
221 | 221 | { |
222 | 222 | $table = $this->prefixTable($table); |
223 | 223 | |
224 | - if (empty($this->queriesResultCache[ 'tableColumns' ][ $table ])) { |
|
224 | + if (empty($this->queriesResultCache['tableColumns'][$table])) { |
|
225 | 225 | $result = $this->query('SHOW COLUMNS FROM ' . $this->protectIdentifiers($table, true, null, false)); |
226 | 226 | |
227 | 227 | if ($result->count()) { |
228 | 228 | foreach ($result as $row) { |
229 | 229 | // Do we know from where to get the column's name? |
230 | 230 | if ( ! isset($key)) { |
231 | - if (isset($row[ 'column_name' ])) { |
|
231 | + if (isset($row['column_name'])) { |
|
232 | 232 | $key = 'column_name'; |
233 | - } elseif (isset($row[ 'COLUMN_NAME' ])) { |
|
233 | + } elseif (isset($row['COLUMN_NAME'])) { |
|
234 | 234 | $key = 'COLUMN_NAME'; |
235 | 235 | } else { |
236 | 236 | /* We have no other choice but to just get the first element's key. |
@@ -243,12 +243,12 @@ discard block |
||
243 | 243 | } |
244 | 244 | } |
245 | 245 | |
246 | - $this->queriesResultCache[ 'tableColumns' ][ $table ][ $row->offsetGet($key) ] = $row; |
|
246 | + $this->queriesResultCache['tableColumns'][$table][$row->offsetGet($key)] = $row; |
|
247 | 247 | } |
248 | 248 | } |
249 | 249 | } |
250 | 250 | |
251 | - return $this->queriesResultCache[ 'tableColumns' ][ $table ]; |
|
251 | + return $this->queriesResultCache['tableColumns'][$table]; |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | // ------------------------------------------------------------------------ |
@@ -327,13 +327,13 @@ discard block |
||
327 | 327 | */ |
328 | 328 | protected function platformGetPlatformInfoHandler() |
329 | 329 | { |
330 | - $server[ 'version' ][ 'string' ] = $this->handle->server_info; |
|
331 | - $server[ 'version' ][ 'number' ] = $this->handle->server_version; |
|
332 | - $server[ 'stats' ] = $this->handle->get_connection_stats(); |
|
330 | + $server['version']['string'] = $this->handle->server_info; |
|
331 | + $server['version']['number'] = $this->handle->server_version; |
|
332 | + $server['stats'] = $this->handle->get_connection_stats(); |
|
333 | 333 | |
334 | - $client[ 'version' ][ 'string' ] = $this->handle->client_info; |
|
335 | - $client[ 'version' ][ 'number' ] = $this->handle->client_version; |
|
336 | - $client[ 'stats' ] = mySqli_get_client_stats(); |
|
334 | + $client['version']['string'] = $this->handle->client_info; |
|
335 | + $client['version']['number'] = $this->handle->client_version; |
|
336 | + $client['stats'] = mySqli_get_client_stats(); |
|
337 | 337 | |
338 | 338 | return new SplArrayObject([ |
339 | 339 | 'name' => $this->getPlatform(), |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | protected function platformConnectHandler(Config $config) |
361 | 361 | { |
362 | 362 | // Do we have a socket path? |
363 | - if ($config->hostname[ 0 ] === '/') { |
|
363 | + if ($config->hostname[0] === '/') { |
|
364 | 364 | $hostname = null; |
365 | 365 | $port = null; |
366 | 366 | $socket = $config->hostname; |
@@ -406,15 +406,15 @@ discard block |
||
406 | 406 | |
407 | 407 | if (is_array($config->encrypt)) { |
408 | 408 | $ssl = []; |
409 | - empty($config->encrypt[ 'ssl_key' ]) OR $ssl[ 'key' ] = $config->encrypt[ 'ssl_key' ]; |
|
410 | - empty($config->encrypt[ 'ssl_cert' ]) OR $ssl[ 'cert' ] = $config->encrypt[ 'ssl_cert' ]; |
|
411 | - empty($config->encrypt[ 'ssl_ca' ]) OR $ssl[ 'ca' ] = $config->encrypt[ 'ssl_ca' ]; |
|
412 | - empty($config->encrypt[ 'ssl_capath' ]) OR $ssl[ 'capath' ] = $config->encrypt[ 'ssl_capath' ]; |
|
413 | - empty($config->encrypt[ 'ssl_cipher' ]) OR $ssl[ 'cipher' ] = $config->encrypt[ 'ssl_cipher' ]; |
|
409 | + empty($config->encrypt['ssl_key']) OR $ssl['key'] = $config->encrypt['ssl_key']; |
|
410 | + empty($config->encrypt['ssl_cert']) OR $ssl['cert'] = $config->encrypt['ssl_cert']; |
|
411 | + empty($config->encrypt['ssl_ca']) OR $ssl['ca'] = $config->encrypt['ssl_ca']; |
|
412 | + empty($config->encrypt['ssl_capath']) OR $ssl['capath'] = $config->encrypt['ssl_capath']; |
|
413 | + empty($config->encrypt['ssl_cipher']) OR $ssl['cipher'] = $config->encrypt['ssl_cipher']; |
|
414 | 414 | |
415 | 415 | if ( ! empty($ssl)) { |
416 | - if (isset($config->encrypt[ 'ssl_verify' ])) { |
|
417 | - if ($config->encrypt[ 'ssl_verify' ]) { |
|
416 | + if (isset($config->encrypt['ssl_verify'])) { |
|
417 | + if ($config->encrypt['ssl_verify']) { |
|
418 | 418 | defined('MYSQLI_OPT_SSL_VERIFY_SERVER_CERT') |
419 | 419 | && $this->handle->options(MYSQLI_OPT_SSL_VERIFY_SERVER_CERT, true); |
420 | 420 | } |
@@ -431,20 +431,20 @@ discard block |
||
431 | 431 | |
432 | 432 | $flags |= MYSQLI_CLIENT_SSL; |
433 | 433 | $this->handle->ssl_set( |
434 | - isset($ssl[ 'key' ]) |
|
435 | - ? $ssl[ 'key' ] |
|
434 | + isset($ssl['key']) |
|
435 | + ? $ssl['key'] |
|
436 | 436 | : null, |
437 | - isset($ssl[ 'cert' ]) |
|
438 | - ? $ssl[ 'cert' ] |
|
437 | + isset($ssl['cert']) |
|
438 | + ? $ssl['cert'] |
|
439 | 439 | : null, |
440 | - isset($ssl[ 'ca' ]) |
|
441 | - ? $ssl[ 'ca' ] |
|
440 | + isset($ssl['ca']) |
|
441 | + ? $ssl['ca'] |
|
442 | 442 | : null, |
443 | - isset($ssl[ 'capath' ]) |
|
444 | - ? $ssl[ 'capath' ] |
|
443 | + isset($ssl['capath']) |
|
444 | + ? $ssl['capath'] |
|
445 | 445 | : null, |
446 | - isset($ssl[ 'cipher' ]) |
|
447 | - ? $ssl[ 'cipher' ] |
|
446 | + isset($ssl['cipher']) |
|
447 | + ? $ssl['cipher'] |
|
448 | 448 | : null |
449 | 449 | ); |
450 | 450 | } |
@@ -544,7 +544,7 @@ discard block |
||
544 | 544 | { |
545 | 545 | $rows = []; |
546 | 546 | |
547 | - if ( $result = $this->handle->query($queryStatement->getSqlFinalStatement()) ) { |
|
547 | + if ($result = $this->handle->query($queryStatement->getSqlFinalStatement())) { |
|
548 | 548 | $rows = $result->fetch_all(MYSQLI_ASSOC); |
549 | 549 | } else { |
550 | 550 | $queryStatement->setError($this->handle->errno, $this->handle->error); |
@@ -564,7 +564,7 @@ discard block |
||
564 | 564 | */ |
565 | 565 | protected function platformTransactionBeginHandler() |
566 | 566 | { |
567 | - if($this->transactionInProgress === false) { |
|
567 | + if ($this->transactionInProgress === false) { |
|
568 | 568 | // Begin transaction using autocommit function set to false |
569 | 569 | $this->handle->autocommit(false); |
570 | 570 |
@@ -186,11 +186,11 @@ discard block |
||
186 | 186 | $columns = []; |
187 | 187 | |
188 | 188 | foreach ($values as $key => $value) { |
189 | - $ids[] = $value[ $index ]; |
|
189 | + $ids[] = $value[$index]; |
|
190 | 190 | |
191 | 191 | foreach (array_keys($value) as $field) { |
192 | 192 | if ($field !== $index) { |
193 | - $columns[ $field ][] = 'WHEN ' . $index . ' = ' . $value[ $index ] . ' THEN ' . $value[ $field ]; |
|
193 | + $columns[$field][] = 'WHEN ' . $index . ' = ' . $value[$index] . ' THEN ' . $value[$field]; |
|
194 | 194 | } |
195 | 195 | } |
196 | 196 | } |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | { |
260 | 260 | $sqlStatement = parent::compileSelectStatement($selectOverride); |
261 | 261 | |
262 | - if($this->isSubQuery) { |
|
262 | + if ($this->isSubQuery) { |
|
263 | 263 | return $sqlStatement; |
264 | 264 | } |
265 | 265 |
@@ -125,9 +125,9 @@ discard block |
||
125 | 125 | */ |
126 | 126 | public function getDatabases() |
127 | 127 | { |
128 | - $this->queriesResultCache[ 'databaseNames' ][] = pathinfo($this->database, PATHINFO_FILENAME); |
|
128 | + $this->queriesResultCache['databaseNames'][] = pathinfo($this->database, PATHINFO_FILENAME); |
|
129 | 129 | |
130 | - return $this->queriesResultCache[ 'databaseNames' ]; |
|
130 | + return $this->queriesResultCache['databaseNames']; |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | // ------------------------------------------------------------------------ |
@@ -144,12 +144,12 @@ discard block |
||
144 | 144 | */ |
145 | 145 | public function getTables($prefixLimit = false) |
146 | 146 | { |
147 | - if (empty($this->queriesResultCache[ 'tableNames' ])) { |
|
147 | + if (empty($this->queriesResultCache['tableNames'])) { |
|
148 | 148 | |
149 | 149 | $sqlStatement = 'SELECT "NAME" FROM "SQLITE_MASTER" WHERE "TYPE" = \'table\''; |
150 | 150 | |
151 | - if ($prefixLimit !== false && $this->config[ 'tablePrefix' ] !== '') { |
|
152 | - $sqlStatement .= ' AND "NAME" LIKE \'' . $this->escapeLikeString($this->config[ 'tablePrefix' ]) . "%' "; |
|
151 | + if ($prefixLimit !== false && $this->config['tablePrefix'] !== '') { |
|
152 | + $sqlStatement .= ' AND "NAME" LIKE \'' . $this->escapeLikeString($this->config['tablePrefix']) . "%' "; |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | $result = $this->query($sqlStatement); |
@@ -158,9 +158,9 @@ discard block |
||
158 | 158 | foreach ($result as $row) { |
159 | 159 | // Do we know from which column to get the table name? |
160 | 160 | if ( ! isset($key)) { |
161 | - if (isset($row[ 'table_name' ])) { |
|
161 | + if (isset($row['table_name'])) { |
|
162 | 162 | $key = 'table_name'; |
163 | - } elseif (isset($row[ 'TABLE_NAME' ])) { |
|
163 | + } elseif (isset($row['TABLE_NAME'])) { |
|
164 | 164 | $key = 'TABLE_NAME'; |
165 | 165 | } else { |
166 | 166 | /* We have no other choice but to just get the first element's key. |
@@ -173,12 +173,12 @@ discard block |
||
173 | 173 | } |
174 | 174 | } |
175 | 175 | |
176 | - $this->queriesResultCache[ 'tableNames' ][] = $row->offsetGet($key); |
|
176 | + $this->queriesResultCache['tableNames'][] = $row->offsetGet($key); |
|
177 | 177 | } |
178 | 178 | } |
179 | 179 | } |
180 | 180 | |
181 | - return $this->queriesResultCache[ 'tableNames' ]; |
|
181 | + return $this->queriesResultCache['tableNames']; |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | // ------------------------------------------------------------------------ |
@@ -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 | // ------------------------------------------------------------------------ |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | if (false !== ($result = $this->handle->query($queryStatement->getSqlFinalStatement()))) { |
333 | 333 | $i = 0; |
334 | 334 | while ($row = $result->fetchArray(SQLITE3_ASSOC)) { |
335 | - $rows[ $i ] = $row; |
|
335 | + $rows[$i] = $row; |
|
336 | 336 | $i++; |
337 | 337 | } |
338 | 338 | } else { |
@@ -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 | } |