@@ -49,17 +49,17 @@ |
||
| 49 | 49 | */ |
| 50 | 50 | protected function registerConfigurationServices() |
| 51 | 51 | { |
| 52 | - $this->app->singleton('db.factory', function ($app) |
|
| 52 | + $this->app->singleton('db.factory', function($app) |
|
| 53 | 53 | { |
| 54 | 54 | return new ConnectionFactory($app); |
| 55 | 55 | }); |
| 56 | 56 | |
| 57 | - $this->app->singleton('db', function ($app) |
|
| 57 | + $this->app->singleton('db', function($app) |
|
| 58 | 58 | { |
| 59 | 59 | return new DatabaseManager($app, $app['db.factory']); |
| 60 | 60 | }); |
| 61 | 61 | |
| 62 | - $this->app->bind('db.connection', function ($app) { |
|
| 62 | + $this->app->bind('db.connection', function($app) { |
|
| 63 | 63 | return $app['db']->connection(); |
| 64 | 64 | }); |
| 65 | 65 | } |
@@ -68,13 +68,13 @@ |
||
| 68 | 68 | return $this->compileInsert($builder, $values).' returning '.$this->wrap($sequence); |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - /** |
|
| 72 | - * Compile a truncate table statement into SQL. |
|
| 73 | - * |
|
| 74 | - * @param \Syscodes\Database\Query\Builder $builder |
|
| 75 | - * |
|
| 76 | - * @return array |
|
| 77 | - */ |
|
| 71 | + /** |
|
| 72 | + * Compile a truncate table statement into SQL. |
|
| 73 | + * |
|
| 74 | + * @param \Syscodes\Database\Query\Builder $builder |
|
| 75 | + * |
|
| 76 | + * @return array |
|
| 77 | + */ |
|
| 78 | 78 | public function truncate(Builder $builder) |
| 79 | 79 | { |
| 80 | 80 | return ['truncate table '.$this->wrapTable($builder->from).' restart identity cascade' => []]; |
@@ -63,7 +63,7 @@ |
||
| 63 | 63 | */ |
| 64 | 64 | public function compileInsertGetId(Builder $builder, $values, $sequence) |
| 65 | 65 | { |
| 66 | - if (is_null($sequence)) $sequence = 'id' ; |
|
| 66 | + if (is_null($sequence)) $sequence = 'id'; |
|
| 67 | 67 | |
| 68 | 68 | return $this->compileInsert($builder, $values).' returning '.$this->wrap($sequence); |
| 69 | 69 | } |
@@ -63,7 +63,9 @@ |
||
| 63 | 63 | */ |
| 64 | 64 | public function compileInsertGetId(Builder $builder, $values, $sequence) |
| 65 | 65 | { |
| 66 | - if (is_null($sequence)) $sequence = 'id' ; |
|
| 66 | + if (is_null($sequence)) { |
|
| 67 | + $sequence = 'id' ; |
|
| 68 | + } |
|
| 67 | 69 | |
| 68 | 70 | return $this->compileInsert($builder, $values).' returning '.$this->wrap($sequence); |
| 69 | 71 | } |
@@ -188,13 +188,13 @@ |
||
| 188 | 188 | return 'select * from ('.$sql.') as '.$this->wrapTable('temp_table'); |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | - /** |
|
| 192 | - * Compile a truncate table statement into SQL. |
|
| 193 | - * |
|
| 194 | - * @param \Syscodes\Database\Query\Builder $builder |
|
| 195 | - * |
|
| 196 | - * @return array |
|
| 197 | - */ |
|
| 191 | + /** |
|
| 192 | + * Compile a truncate table statement into SQL. |
|
| 193 | + * |
|
| 194 | + * @param \Syscodes\Database\Query\Builder $builder |
|
| 195 | + * |
|
| 196 | + * @return array |
|
| 197 | + */ |
|
| 198 | 198 | public function truncate(Builder $builder) |
| 199 | 199 | { |
| 200 | 200 | return ['truncate table '.$this->wrapTable($builder->from) => []]; |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | { |
| 323 | 323 | $this->addSelect(new Expression($expression)); |
| 324 | 324 | |
| 325 | - if (! empty($bindings)) |
|
| 325 | + if ( ! empty($bindings)) |
|
| 326 | 326 | { |
| 327 | 327 | $this->addBinding($bindings, 'select'); |
| 328 | 328 | } |
@@ -439,7 +439,7 @@ discard block |
||
| 439 | 439 | */ |
| 440 | 440 | protected function addArrayWheres($column, $boolean, $method = 'where') |
| 441 | 441 | { |
| 442 | - return $this->whereNested(function ($query) use ($column, $method, $boolean) |
|
| 442 | + return $this->whereNested(function($query) use ($column, $method, $boolean) |
|
| 443 | 443 | { |
| 444 | 444 | foreach ($column as $key => $value) |
| 445 | 445 | { |
@@ -776,7 +776,7 @@ discard block |
||
| 776 | 776 | */ |
| 777 | 777 | public function get($columns = ['*']) |
| 778 | 778 | { |
| 779 | - return collect($this->getFresh(Arr::wrap($columns), function () { |
|
| 779 | + return collect($this->getFresh(Arr::wrap($columns), function() { |
|
| 780 | 780 | return $this->getWithStatement(); |
| 781 | 781 | })); |
| 782 | 782 | } |
@@ -1228,7 +1228,7 @@ discard block |
||
| 1228 | 1228 | */ |
| 1229 | 1229 | public function cleanBindings(array $bindings) |
| 1230 | 1230 | { |
| 1231 | - return array_values(array_filter($bindings, function ($binding) { |
|
| 1231 | + return array_values(array_filter($bindings, function($binding) { |
|
| 1232 | 1232 | return ! $binding instanceof Expression; |
| 1233 | 1233 | })); |
| 1234 | 1234 | } |
@@ -299,12 +299,10 @@ discard block |
||
| 299 | 299 | if ($builder instanceof self) |
| 300 | 300 | { |
| 301 | 301 | return [$builder->getSql(), $builder->getBindings()]; |
| 302 | - } |
|
| 303 | - elseif (is_string($builder)) |
|
| 302 | + } elseif (is_string($builder)) |
|
| 304 | 303 | { |
| 305 | 304 | return [$builder->getSql(), []]; |
| 306 | - } |
|
| 307 | - else |
|
| 305 | + } else |
|
| 308 | 306 | { |
| 309 | 307 | throw new InvalidArgumentException('A subquery must be a query builder instance, a Closure, or a string'); |
| 310 | 308 | } |
@@ -446,8 +444,7 @@ discard block |
||
| 446 | 444 | if (is_numeric($key) && is_array($value)) |
| 447 | 445 | { |
| 448 | 446 | $query->{$method}(...array_values($value)); |
| 449 | - } |
|
| 450 | - else |
|
| 447 | + } else |
|
| 451 | 448 | { |
| 452 | 449 | $query->{$method}($key, '=', $value, $boolean); |
| 453 | 450 | } |
@@ -471,8 +468,7 @@ discard block |
||
| 471 | 468 | if ($useDefault) |
| 472 | 469 | { |
| 473 | 470 | return [$operator, '=']; |
| 474 | - } |
|
| 475 | - elseif ($this->invalidOperatorValue($operator, $value)) |
|
| 471 | + } elseif ($this->invalidOperatorValue($operator, $value)) |
|
| 476 | 472 | { |
| 477 | 473 | throw new InvalidArgumentException('Illegal operator and value combination.'); |
| 478 | 474 | } |
@@ -932,8 +928,7 @@ discard block |
||
| 932 | 928 | if ( ! is_array(reset($values))) |
| 933 | 929 | { |
| 934 | 930 | $values = [$values]; |
| 935 | - } |
|
| 936 | - else |
|
| 931 | + } else |
|
| 937 | 932 | { |
| 938 | 933 | foreach ($values as $key => $value) |
| 939 | 934 | { |
@@ -1296,8 +1291,7 @@ discard block |
||
| 1296 | 1291 | if (is_array($value)) |
| 1297 | 1292 | { |
| 1298 | 1293 | $this->bindings[$type] = array_values(array_merge($this->bindings[$type], $value)); |
| 1299 | - } |
|
| 1300 | - else |
|
| 1294 | + } else |
|
| 1301 | 1295 | { |
| 1302 | 1296 | $this->bindings[$type][] = $value; |
| 1303 | 1297 | } |
@@ -41,7 +41,7 @@ |
||
| 41 | 41 | */ |
| 42 | 42 | public function processColumnListing($results) |
| 43 | 43 | { |
| 44 | - return array_map(function ($result) { |
|
| 44 | + return array_map(function($result) { |
|
| 45 | 45 | return ((object) $result)->column_name; |
| 46 | 46 | }, $results); |
| 47 | 47 | } |
@@ -41,7 +41,7 @@ |
||
| 41 | 41 | */ |
| 42 | 42 | public function accessColumnListing($results) |
| 43 | 43 | { |
| 44 | - return array_map(function ($result) { |
|
| 44 | + return array_map(function($result) { |
|
| 45 | 45 | return ((object) $result)->column_name; |
| 46 | 46 | }, $results); |
| 47 | 47 | } |
@@ -207,17 +207,17 @@ discard block |
||
| 207 | 207 | */ |
| 208 | 208 | protected function compileWheres(Builder $builder) |
| 209 | 209 | { |
| 210 | - if (is_null($builder->wheres)) |
|
| 211 | - { |
|
| 212 | - return ''; |
|
| 213 | - } |
|
| 210 | + if (is_null($builder->wheres)) |
|
| 211 | + { |
|
| 212 | + return ''; |
|
| 213 | + } |
|
| 214 | 214 | |
| 215 | - if (count($sql = $this->compileWheresToArray($builder)) > 0) |
|
| 216 | - { |
|
| 215 | + if (count($sql = $this->compileWheresToArray($builder)) > 0) |
|
| 216 | + { |
|
| 217 | 217 | return $this->concatenateWheresClauses($builder, $sql); |
| 218 | - } |
|
| 218 | + } |
|
| 219 | 219 | |
| 220 | - return ''; |
|
| 220 | + return ''; |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | /** |
@@ -940,7 +940,7 @@ discard block |
||
| 940 | 940 | */ |
| 941 | 941 | public function compileUpdateWithoutJoins(Builder $builder, $table, $columns, $where) |
| 942 | 942 | { |
| 943 | - return "update {$table} set {$columns} {$where}"; |
|
| 943 | + return "update {$table} set {$columns} {$where}"; |
|
| 944 | 944 | } |
| 945 | 945 | |
| 946 | 946 | /** |
@@ -993,7 +993,7 @@ discard block |
||
| 993 | 993 | */ |
| 994 | 994 | public function compileDeleteWithoutJoins(Builder $builder, $table, $where) |
| 995 | 995 | { |
| 996 | - return "delete from {$table} {$where}"; |
|
| 996 | + return "delete from {$table} {$where}"; |
|
| 997 | 997 | } |
| 998 | 998 | |
| 999 | 999 | /** |
@@ -691,7 +691,7 @@ discard block |
||
| 691 | 691 | */ |
| 692 | 692 | protected function compileOrderToArray(Builder $builder, $orders) |
| 693 | 693 | { |
| 694 | - return array_map(function ($order) { |
|
| 694 | + return array_map(function($order) { |
|
| 695 | 695 | return $order['sql'] ?? $this->wrap($order['column']).' '.$order['direction']; |
| 696 | 696 | }, $orders); |
| 697 | 697 | } |
@@ -1030,7 +1030,7 @@ discard block |
||
| 1030 | 1030 | */ |
| 1031 | 1031 | protected function concatenate($segments) |
| 1032 | 1032 | { |
| 1033 | - return implode(' ', array_filter($segments, function ($value) { |
|
| 1033 | + return implode(' ', array_filter($segments, function($value) { |
|
| 1034 | 1034 | return (string) $value !== ''; |
| 1035 | 1035 | })); |
| 1036 | 1036 | } |
@@ -619,8 +619,7 @@ |
||
| 619 | 619 | if ($having['type'] === 'raw') |
| 620 | 620 | { |
| 621 | 621 | return $having['boolean'].' '.$having['sql']; |
| 622 | - } |
|
| 623 | - elseif ($having['type'] === 'between') |
|
| 622 | + } elseif ($having['type'] === 'between') |
|
| 624 | 623 | { |
| 625 | 624 | return $this->compileHavingBetween($having); |
| 626 | 625 | } |
@@ -182,7 +182,7 @@ |
||
| 182 | 182 | $connection->setEventDispatcher($this->app['events']); |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | - $connection->setReconnector(function ($connection) |
|
| 185 | + $connection->setReconnector(function($connection) |
|
| 186 | 186 | { |
| 187 | 187 | $this->reconnect($connection->getName()); |
| 188 | 188 | }); |
@@ -203,8 +203,7 @@ |
||
| 203 | 203 | if ($type === 'read') |
| 204 | 204 | { |
| 205 | 205 | $connection->setPdo($connection->getReadPdo()); |
| 206 | - } |
|
| 207 | - elseif ($type === 'write') |
|
| 206 | + } elseif ($type === 'write') |
|
| 208 | 207 | { |
| 209 | 208 | $connection->setReadPdo($connection->getPdo()); |
| 210 | 209 | } |
@@ -66,13 +66,13 @@ |
||
| 66 | 66 | return $connection; |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - /** |
|
| 70 | - * Create a DSN string from a configuration. |
|
| 71 | - * |
|
| 72 | - * @param array $config |
|
| 73 | - * |
|
| 74 | - * @return string |
|
| 75 | - */ |
|
| 69 | + /** |
|
| 70 | + * Create a DSN string from a configuration. |
|
| 71 | + * |
|
| 72 | + * @param array $config |
|
| 73 | + * |
|
| 74 | + * @return string |
|
| 75 | + */ |
|
| 76 | 76 | protected function getDsn(array $config) |
| 77 | 77 | { |
| 78 | 78 | extract($config, EXTR_SKIP); |