@@ -71,7 +71,7 @@ |
||
| 71 | 71 | $this->softDetect($sql); |
| 72 | 72 | $statement = \ibase_prepare($this->transaction !== null ? $this->transaction : $this->lnk, $sql); |
| 73 | 73 | if ($statement === false) { |
| 74 | - throw new DBException('Prepare error: ' . \ibase_errmsg()); |
|
| 74 | + throw new DBException('Prepare error: '.\ibase_errmsg()); |
|
| 75 | 75 | } |
| 76 | 76 | return new Statement( |
| 77 | 77 | $statement, |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | $this->query("ALTER SESSION SET time_zone = '".addslashes($timezone)."'"); |
| 45 | 45 | } |
| 46 | 46 | if ($schema = $this->option('schema')) { |
| 47 | - $this->query("ALTER SESSION SET CURRENT_SCHEMA = " . $schema); |
|
| 47 | + $this->query("ALTER SESSION SET CURRENT_SCHEMA = ".$schema); |
|
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | } |
@@ -81,11 +81,11 @@ discard block |
||
| 81 | 81 | ); |
| 82 | 82 | if ($log) { |
| 83 | 83 | $tm = microtime(true) - $tm; |
| 84 | - if ($tm >= (float)$this->option('log_slow', 0)) { |
|
| 84 | + if ($tm >= (float) $this->option('log_slow', 0)) { |
|
| 85 | 85 | @file_put_contents( |
| 86 | 86 | $log, |
| 87 | - '--' . date('Y-m-d H:i:s') . ' ' . sprintf('%01.6f', $tm) . "s\r\n" . |
|
| 88 | - $sql . "\r\n" . |
|
| 87 | + '--'.date('Y-m-d H:i:s').' '.sprintf('%01.6f', $tm)."s\r\n". |
|
| 88 | + $sql."\r\n". |
|
| 89 | 89 | "\r\n", |
| 90 | 90 | FILE_APPEND |
| 91 | 91 | ); |
@@ -45,11 +45,11 @@ discard block |
||
| 45 | 45 | if (isset($this->connection['opts']['search_path'])) { |
| 46 | 46 | @\pg_query( |
| 47 | 47 | $this->lnk, |
| 48 | - "SET search_path TO " . pg_escape_string($this->connection['opts']['search_path']) |
|
| 48 | + "SET search_path TO ".pg_escape_string($this->connection['opts']['search_path']) |
|
| 49 | 49 | ); |
| 50 | 50 | } |
| 51 | 51 | if (!isset($this->connection['opts']['search_path']) && isset($this->connection['opts']['schema'])) { |
| 52 | - @\pg_query($this->lnk, "SET search_path TO " . pg_escape_string($this->connection['opts']['schema'])); |
|
| 52 | + @\pg_query($this->lnk, "SET search_path TO ".pg_escape_string($this->connection['opts']['schema'])); |
|
| 53 | 53 | } |
| 54 | 54 | if (isset($this->connection['opts']['timezone'])) { |
| 55 | 55 | @\pg_query($this->lnk, "SET TIME ZONE '".pg_escape_string($this->connection['opts']['timezone'])."'"); |
@@ -87,11 +87,11 @@ discard block |
||
| 87 | 87 | $res = \pg_query($this->lnk, $sql); |
| 88 | 88 | if ($log) { |
| 89 | 89 | $tm = microtime(true) - $tm; |
| 90 | - if ($tm >= (float)$this->option('log_slow', 0)) { |
|
| 90 | + if ($tm >= (float) $this->option('log_slow', 0)) { |
|
| 91 | 91 | @file_put_contents( |
| 92 | 92 | $log, |
| 93 | - '--' . date('Y-m-d H:i:s') . ' ' . sprintf('%01.6f', $tm) . "s\r\n" . |
|
| 94 | - $sql . "\r\n" . |
|
| 93 | + '--'.date('Y-m-d H:i:s').' '.sprintf('%01.6f', $tm)."s\r\n". |
|
| 94 | + $sql."\r\n". |
|
| 95 | 95 | "\r\n", |
| 96 | 96 | FILE_APPEND |
| 97 | 97 | ); |
@@ -37,8 +37,7 @@ discard block |
||
| 37 | 37 | $temp = @\pg_query( |
| 38 | 38 | $this->driver, |
| 39 | 39 | $sequence ? |
| 40 | - 'SELECT currval('.@\pg_escape_string($this->driver, $sequence).')' : |
|
| 41 | - 'SELECT lastval()' |
|
| 40 | + 'SELECT currval('.@\pg_escape_string($this->driver, $sequence).')' : 'SELECT lastval()' |
|
| 42 | 41 | ); |
| 43 | 42 | if ($temp) { |
| 44 | 43 | $res = \pg_fetch_row($temp); |
@@ -76,8 +75,8 @@ discard block |
||
| 76 | 75 | } |
| 77 | 76 | public function next(): void |
| 78 | 77 | { |
| 79 | - $this->fetched ++; |
|
| 80 | - $this->last = \pg_fetch_array($this->statement, null, \PGSQL_ASSOC)?:null; |
|
| 78 | + $this->fetched++; |
|
| 79 | + $this->last = \pg_fetch_array($this->statement, null, \PGSQL_ASSOC) ?: null; |
|
| 81 | 80 | if (is_array($this->last)) { |
| 82 | 81 | $this->cast(); |
| 83 | 82 | } |
@@ -90,11 +89,11 @@ discard block |
||
| 90 | 89 | protected function cast(): void |
| 91 | 90 | { |
| 92 | 91 | if (!count($this->types)) { |
| 93 | - foreach (array_keys($this->last??[]) as $k => $v) { |
|
| 92 | + foreach (array_keys($this->last ?? []) as $k => $v) { |
|
| 94 | 93 | $this->types[$v] = \pg_field_type($this->statement, $k); |
| 95 | 94 | } |
| 96 | 95 | } |
| 97 | - foreach ($this->last??[] as $k => $v) { |
|
| 96 | + foreach ($this->last ?? [] as $k => $v) { |
|
| 98 | 97 | if (is_null($v) || !isset($this->types[$k])) { |
| 99 | 98 | continue; |
| 100 | 99 | } |
@@ -102,15 +101,15 @@ discard block |
||
| 102 | 101 | case 'int2': |
| 103 | 102 | case 'int4': |
| 104 | 103 | case 'int8': |
| 105 | - $this->last[$k] = (int)$v; |
|
| 104 | + $this->last[$k] = (int) $v; |
|
| 106 | 105 | break; |
| 107 | 106 | case 'bit': |
| 108 | 107 | case 'bool': |
| 109 | - $this->last[$k] = $v !== 'f' && (int)$v ? true : false; |
|
| 108 | + $this->last[$k] = $v !== 'f' && (int) $v ? true : false; |
|
| 110 | 109 | break; |
| 111 | 110 | case 'float4': |
| 112 | 111 | case 'float8': |
| 113 | - $this->last[$k] = (float)$v; |
|
| 112 | + $this->last[$k] = (float) $v; |
|
| 114 | 113 | break; |
| 115 | 114 | case 'money': |
| 116 | 115 | case 'numeric': |
@@ -38,7 +38,7 @@ |
||
| 38 | 38 | if ($this->lnk === null) { |
| 39 | 39 | try { |
| 40 | 40 | $this->lnk = new \SQLite3($this->connection['name']); |
| 41 | - $this->lnk->exec('PRAGMA encoding = "'.$this->option('charset', 'utf-8') . '"'); |
|
| 41 | + $this->lnk->exec('PRAGMA encoding = "'.$this->option('charset', 'utf-8').'"'); |
|
| 42 | 42 | } catch (\Exception $e) { |
| 43 | 43 | if ($this->lnk !== null) { |
| 44 | 44 | throw new DBException('Connect error: '.$this->lnk->lastErrorMsg()); |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | $instance->setNullable($data['nullable']); |
| 43 | 43 | } |
| 44 | 44 | if (isset($data['notnull'])) { |
| 45 | - $instance->setNullable(!((int)$data['notnull'])); |
|
| 45 | + $instance->setNullable(!((int) $data['notnull'])); |
|
| 46 | 46 | } |
| 47 | 47 | if (isset($data['Default'])) { |
| 48 | 48 | $instance->setDefault($data['Default']); |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | $instance->setLength($data['length']); |
| 58 | 58 | } |
| 59 | 59 | if ($instance->getBasicType() === 'enum' && strpos($instance->getType(), 'enum(') === 0) { |
| 60 | - $temp = array_map(function ($v) { |
|
| 60 | + $temp = array_map(function($v) { |
|
| 61 | 61 | return str_replace("''", "'", $v); |
| 62 | 62 | }, explode("','", substr($instance->getType(), 6, -2))); |
| 63 | 63 | $instance->setValues($temp); |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | $instance->setDefault(null); |
| 87 | 87 | } |
| 88 | 88 | } |
| 89 | - if ($instance->getBasicType() === 'text' && isset($data['CHAR_LENGTH']) && (int)$data['CHAR_LENGTH']) { |
|
| 89 | + if ($instance->getBasicType() === 'text' && isset($data['CHAR_LENGTH']) && (int) $data['CHAR_LENGTH']) { |
|
| 90 | 90 | $instance->setLength($data['CHAR_LENGTH']); |
| 91 | 91 | } |
| 92 | 92 | return $instance; |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | } |
| 184 | 184 | public function getLength(): int |
| 185 | 185 | { |
| 186 | - return (int)$this->length; |
|
| 186 | + return (int) $this->length; |
|
| 187 | 187 | } |
| 188 | 188 | public function setLength(int $length): static |
| 189 | 189 | { |
@@ -58,12 +58,12 @@ |
||
| 58 | 58 | * @param array|T $entity |
| 59 | 59 | * @return bool |
| 60 | 60 | */ |
| 61 | - public function deleted(array|object $entity): bool; |
|
| 61 | + public function deleted(array | object $entity): bool; |
|
| 62 | 62 | /** |
| 63 | 63 | * @param array|T $entity |
| 64 | 64 | * @return bool |
| 65 | 65 | */ |
| 66 | - public function exists(array|object $entity): bool; |
|
| 66 | + public function exists(array | object $entity): bool; |
|
| 67 | 67 | /** |
| 68 | 68 | * @return array<int,T> |
| 69 | 69 | */ |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | public function getTable(string $table): Table |
| 32 | 32 | { |
| 33 | 33 | if (!$this->hasTable($table)) { |
| 34 | - throw new DBException('Invalid table name: ' . $table); |
|
| 34 | + throw new DBException('Invalid table name: '.$table); |
|
| 35 | 35 | } |
| 36 | 36 | return $this->tables[$table] ?? |
| 37 | 37 | $this->tables[strtoupper($table)] ?? |
@@ -64,13 +64,13 @@ discard block |
||
| 64 | 64 | |
| 65 | 65 | public function toArray(): array |
| 66 | 66 | { |
| 67 | - return array_map(function ($table) { |
|
| 67 | + return array_map(function($table) { |
|
| 68 | 68 | return [ |
| 69 | 69 | 'name' => $table->getName(), |
| 70 | 70 | 'schema' => $table->getSchema(), |
| 71 | 71 | 'pkey' => $table->getPrimaryKey(), |
| 72 | 72 | 'comment' => $table->getComment(), |
| 73 | - 'columns' => array_map(function ($column) { |
|
| 73 | + 'columns' => array_map(function($column) { |
|
| 74 | 74 | return [ |
| 75 | 75 | 'name' => $column->getName(), |
| 76 | 76 | 'type' => $column->getType(), |
@@ -81,9 +81,9 @@ discard block |
||
| 81 | 81 | 'nullable' => $column->isNullable() |
| 82 | 82 | ]; |
| 83 | 83 | }, $table->getFullColumns()), |
| 84 | - 'relations' => array_map(function ($rel) { |
|
| 84 | + 'relations' => array_map(function($rel) { |
|
| 85 | 85 | $relation = clone $rel; |
| 86 | - $relation = (array)$relation; |
|
| 86 | + $relation = (array) $relation; |
|
| 87 | 87 | $relation['table'] = $rel->table->getName(); |
| 88 | 88 | if ($rel->pivot) { |
| 89 | 89 | $relation['pivot'] = $rel->pivot->getName(); |
@@ -27,8 +27,8 @@ discard block |
||
| 27 | 27 | $table = $temp[1]; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | - if (isset($tables[$schema . '.' . $table])) { |
|
| 31 | - return $tables[$schema . '.' . $table]; |
|
| 30 | + if (isset($tables[$schema.'.'.$table])) { |
|
| 31 | + return $tables[$schema.'.'.$table]; |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | static $comments = []; |
@@ -36,10 +36,10 @@ discard block |
||
| 36 | 36 | $comments[$schema] = Collection::from( |
| 37 | 37 | $this->query( |
| 38 | 38 | "SELECT TABLE_NAME, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = ?", |
| 39 | - [ $schema ] |
|
| 39 | + [$schema] |
|
| 40 | 40 | ) |
| 41 | 41 | ) |
| 42 | - ->mapKey(function (array $v): string { |
|
| 42 | + ->mapKey(function(array $v): string { |
|
| 43 | 43 | return $v['TABLE_NAME']; |
| 44 | 44 | }) |
| 45 | 45 | ->pluck('TABLE_COMMENT') |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | WHERE |
| 62 | 62 | (TABLE_SCHEMA = ? OR REFERENCED_TABLE_SCHEMA = ?) AND |
| 63 | 63 | TABLE_NAME IS NOT NULL AND REFERENCED_TABLE_NAME IS NOT NULL", |
| 64 | - [ $main, $main ] |
|
| 64 | + [$main, $main] |
|
| 65 | 65 | ) |
| 66 | 66 | )->toArray(); |
| 67 | 67 | foreach ($col as $row) { |
@@ -71,8 +71,8 @@ discard block |
||
| 71 | 71 | if ($row['REFERENCED_TABLE_SCHEMA'] !== $main) { |
| 72 | 72 | $additional[] = $row['REFERENCED_TABLE_SCHEMA']; |
| 73 | 73 | } |
| 74 | - $relationsT[$row['TABLE_SCHEMA'] . '.' . $row['TABLE_NAME']][] = $row; |
|
| 75 | - $relationsR[$row['REFERENCED_TABLE_SCHEMA'] . '.' . $row['REFERENCED_TABLE_NAME']][] = $row; |
|
| 74 | + $relationsT[$row['TABLE_SCHEMA'].'.'.$row['TABLE_NAME']][] = $row; |
|
| 75 | + $relationsR[$row['REFERENCED_TABLE_SCHEMA'].'.'.$row['REFERENCED_TABLE_NAME']][] = $row; |
|
| 76 | 76 | } |
| 77 | 77 | foreach (array_filter(array_unique($additional)) as $s) { |
| 78 | 78 | $col = Collection::from( |
@@ -84,12 +84,12 @@ discard block |
||
| 84 | 84 | WHERE |
| 85 | 85 | TABLE_SCHEMA = ? AND REFERENCED_TABLE_SCHEMA = ? AND |
| 86 | 86 | TABLE_NAME IS NOT NULL AND REFERENCED_TABLE_NAME IS NOT NULL", |
| 87 | - [ $s, $s ] |
|
| 87 | + [$s, $s] |
|
| 88 | 88 | ) |
| 89 | 89 | )->toArray(); |
| 90 | 90 | foreach ($col as $row) { |
| 91 | - $relationsT[$row['TABLE_SCHEMA'] . '.' . $row['TABLE_NAME']][] = $row; |
|
| 92 | - $relationsR[$row['REFERENCED_TABLE_SCHEMA'] . '.' . $row['REFERENCED_TABLE_NAME']][] = $row; |
|
| 91 | + $relationsT[$row['TABLE_SCHEMA'].'.'.$row['TABLE_NAME']][] = $row; |
|
| 92 | + $relationsR[$row['REFERENCED_TABLE_SCHEMA'].'.'.$row['REFERENCED_TABLE_NAME']][] = $row; |
|
| 93 | 93 | } |
| 94 | 94 | } |
| 95 | 95 | |
@@ -99,14 +99,14 @@ discard block |
||
| 99 | 99 | if (!count($columns)) { |
| 100 | 100 | throw new DBException('Table not found by name'); |
| 101 | 101 | } |
| 102 | - $tables[$schema . '.' . $table] = $definition = (new Table($table, $schema)) |
|
| 102 | + $tables[$schema.'.'.$table] = $definition = (new Table($table, $schema)) |
|
| 103 | 103 | ->addColumns( |
| 104 | 104 | $columns |
| 105 | 105 | ->clone() |
| 106 | - ->mapKey(function (array $v): string { |
|
| 106 | + ->mapKey(function(array $v): string { |
|
| 107 | 107 | return $v['Field']; |
| 108 | 108 | }) |
| 109 | - ->map(function (array $v): array { |
|
| 109 | + ->map(function(array $v): array { |
|
| 110 | 110 | $v['length'] = null; |
| 111 | 111 | if (!isset($v['Type'])) { |
| 112 | 112 | return $v; |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | default: |
| 129 | 129 | if (strpos($type, 'char') !== false && strpos($type, '(') !== false) { |
| 130 | 130 | // extract length from varchar |
| 131 | - $v['length'] = (int)explode(')', explode('(', $type)[1])[0]; |
|
| 131 | + $v['length'] = (int) explode(')', explode('(', $type)[1])[0]; |
|
| 132 | 132 | $v['length'] = $v['length'] > 0 ? $v['length'] : null; |
| 133 | 133 | } |
| 134 | 134 | break; |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | ->setPrimaryKey( |
| 141 | 141 | $columns |
| 142 | 142 | ->clone() |
| 143 | - ->filter(function (array $v): bool { |
|
| 143 | + ->filter(function(array $v): bool { |
|
| 144 | 144 | return $v['Key'] === 'PRI'; |
| 145 | 145 | }) |
| 146 | 146 | ->pluck('Field') |
@@ -151,20 +151,20 @@ discard block |
||
| 151 | 151 | |
| 152 | 152 | if ($detectRelations) { |
| 153 | 153 | $duplicated = []; |
| 154 | - foreach ($relationsT[$schema . '.' . $table] ?? [] as $relation) { |
|
| 155 | - $t = $relation['REFERENCED_TABLE_SCHEMA'] . '.' . $relation['REFERENCED_TABLE_NAME']; |
|
| 154 | + foreach ($relationsT[$schema.'.'.$table] ?? [] as $relation) { |
|
| 155 | + $t = $relation['REFERENCED_TABLE_SCHEMA'].'.'.$relation['REFERENCED_TABLE_NAME']; |
|
| 156 | 156 | $duplicated[$t] = isset($duplicated[$t]); |
| 157 | 157 | } |
| 158 | - foreach ($relationsR[$schema . '.' . $table] ?? [] as $relation) { |
|
| 159 | - $t = $relation['TABLE_SCHEMA'] . '.' . $relation['TABLE_NAME']; |
|
| 158 | + foreach ($relationsR[$schema.'.'.$table] ?? [] as $relation) { |
|
| 159 | + $t = $relation['TABLE_SCHEMA'].'.'.$relation['TABLE_NAME']; |
|
| 160 | 160 | $duplicated[$t] = isset($duplicated[$t]); |
| 161 | 161 | } |
| 162 | 162 | // pivot relations where the current table is referenced |
| 163 | 163 | // assuming current table is on the "one" end having "many" records in the referencing table |
| 164 | 164 | // resulting in a "hasMany" or "manyToMany" relationship (if a pivot table is detected) |
| 165 | 165 | $relations = []; |
| 166 | - foreach ($relationsR[$schema . '.' . $table] ?? [] as $relation) { |
|
| 167 | - $relations[$relation['CONSTRAINT_NAME']]['table'] = $relation['TABLE_SCHEMA'] . '.' . |
|
| 166 | + foreach ($relationsR[$schema.'.'.$table] ?? [] as $relation) { |
|
| 167 | + $relations[$relation['CONSTRAINT_NAME']]['table'] = $relation['TABLE_SCHEMA'].'.'. |
|
| 168 | 168 | $relation['TABLE_NAME']; |
| 169 | 169 | $relations[$relation['CONSTRAINT_NAME']]['keymap'][$relation['REFERENCED_COLUMN_NAME']] = |
| 170 | 170 | $relation['COLUMN_NAME']; |
@@ -181,10 +181,10 @@ discard block |
||
| 181 | 181 | $usedcol = []; |
| 182 | 182 | if (count($columns)) { |
| 183 | 183 | foreach (Collection::from($relationsT[$data['table']] ?? []) |
| 184 | - ->filter(function (array $v) use ($columns): bool { |
|
| 184 | + ->filter(function(array $v) use ($columns): bool { |
|
| 185 | 185 | return in_array($v['COLUMN_NAME'], $columns); |
| 186 | 186 | }) |
| 187 | - ->map(function (array $v): array { |
|
| 187 | + ->map(function(array $v): array { |
|
| 188 | 188 | $new = []; |
| 189 | 189 | foreach ($v as $kk => $vv) { |
| 190 | 190 | $new[strtoupper($kk)] = $vv; |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | return $new; |
| 193 | 193 | }) as $relation |
| 194 | 194 | ) { |
| 195 | - $foreign[$relation['CONSTRAINT_NAME']]['table'] = $relation['REFERENCED_TABLE_SCHEMA'] . '.' . |
|
| 195 | + $foreign[$relation['CONSTRAINT_NAME']]['table'] = $relation['REFERENCED_TABLE_SCHEMA'].'.'. |
|
| 196 | 196 | $relation['REFERENCED_TABLE_NAME']; |
| 197 | 197 | $foreign[$relation['CONSTRAINT_NAME']]['keymap'][$relation['COLUMN_NAME']] = |
| 198 | 198 | $relation['REFERENCED_COLUMN_NAME']; |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | $orig = $relname; |
| 210 | 210 | $cntr = 1; |
| 211 | 211 | while ($definition->hasRelation($relname) || $definition->getName() == $relname) { |
| 212 | - $relname = $orig . '_' . (++ $cntr); |
|
| 212 | + $relname = $orig.'_'.(++$cntr); |
|
| 213 | 213 | } |
| 214 | 214 | $definition->addRelation( |
| 215 | 215 | new TableRelation( |
@@ -231,8 +231,8 @@ discard block |
||
| 231 | 231 | // assuming current table is linked to "one" record in the referenced table |
| 232 | 232 | // resulting in a "belongsTo" relationship |
| 233 | 233 | $relations = []; |
| 234 | - foreach ($relationsT[$schema . '.' . $table] ?? [] as $relation) { |
|
| 235 | - $relations[$relation['CONSTRAINT_NAME']]['table'] = $relation['REFERENCED_TABLE_SCHEMA'] . '.' . |
|
| 234 | + foreach ($relationsT[$schema.'.'.$table] ?? [] as $relation) { |
|
| 235 | + $relations[$relation['CONSTRAINT_NAME']]['table'] = $relation['REFERENCED_TABLE_SCHEMA'].'.'. |
|
| 236 | 236 | $relation['REFERENCED_TABLE_NAME']; |
| 237 | 237 | $relations[$relation['CONSTRAINT_NAME']]['keymap'][$relation['COLUMN_NAME']] = |
| 238 | 238 | $relation['REFERENCED_COLUMN_NAME']; |
@@ -248,12 +248,12 @@ discard block |
||
| 248 | 248 | $definition->getName() == $relname || |
| 249 | 249 | $definition->getColumn($relname) |
| 250 | 250 | ) { |
| 251 | - $relname = array_keys($data['keymap'])[0] . '_' . $relname; |
|
| 251 | + $relname = array_keys($data['keymap'])[0].'_'.$relname; |
|
| 252 | 252 | } |
| 253 | 253 | $orig = $relname; |
| 254 | 254 | $cntr = 1; |
| 255 | 255 | while ($definition->hasRelation($relname) || $definition->getName() == $relname) { |
| 256 | - $relname = $orig . '_' . (++ $cntr); |
|
| 256 | + $relname = $orig.'_'.(++$cntr); |
|
| 257 | 257 | } |
| 258 | 258 | $definition->addRelation( |
| 259 | 259 | new TableRelation( |
@@ -269,8 +269,8 @@ discard block |
||
| 269 | 269 | // assuming current table is on the "one" end having "many" records in the referencing table |
| 270 | 270 | // resulting in a "hasMany" or "manyToMany" relationship (if a pivot table is detected) |
| 271 | 271 | $relations = []; |
| 272 | - foreach ($relationsR[$schema . '.' . $table] ?? [] as $relation) { |
|
| 273 | - $relations[$relation['CONSTRAINT_NAME']]['table'] = $relation['TABLE_SCHEMA'] . '.' . |
|
| 272 | + foreach ($relationsR[$schema.'.'.$table] ?? [] as $relation) { |
|
| 273 | + $relations[$relation['CONSTRAINT_NAME']]['table'] = $relation['TABLE_SCHEMA'].'.'. |
|
| 274 | 274 | $relation['TABLE_NAME']; |
| 275 | 275 | $relations[$relation['CONSTRAINT_NAME']]['keymap'][$relation['REFERENCED_COLUMN_NAME']] = |
| 276 | 276 | $relation['COLUMN_NAME']; |
@@ -287,10 +287,10 @@ discard block |
||
| 287 | 287 | $usedcol = []; |
| 288 | 288 | if (count($columns)) { |
| 289 | 289 | foreach (Collection::from($relationsT[$data['table']] ?? []) |
| 290 | - ->filter(function (array $v) use ($columns): bool { |
|
| 290 | + ->filter(function(array $v) use ($columns): bool { |
|
| 291 | 291 | return in_array($v['COLUMN_NAME'], $columns); |
| 292 | 292 | }) |
| 293 | - ->map(function (array $v): array { |
|
| 293 | + ->map(function(array $v): array { |
|
| 294 | 294 | $new = []; |
| 295 | 295 | foreach ($v as $kk => $vv) { |
| 296 | 296 | $new[strtoupper($kk)] = $vv; |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | return $new; |
| 299 | 299 | }) as $relation |
| 300 | 300 | ) { |
| 301 | - $foreign[$relation['CONSTRAINT_NAME']]['table'] = $relation['REFERENCED_TABLE_SCHEMA'] . '.' . |
|
| 301 | + $foreign[$relation['CONSTRAINT_NAME']]['table'] = $relation['REFERENCED_TABLE_SCHEMA'].'.'. |
|
| 302 | 302 | $relation['REFERENCED_TABLE_NAME']; |
| 303 | 303 | $foreign[$relation['CONSTRAINT_NAME']]['keymap'][$relation['COLUMN_NAME']] = |
| 304 | 304 | $relation['REFERENCED_COLUMN_NAME']; |
@@ -316,12 +316,12 @@ discard block |
||
| 316 | 316 | $definition->getName() == $relname || |
| 317 | 317 | $definition->getColumn($relname) |
| 318 | 318 | ) { |
| 319 | - $relname .= '_' . array_values($data['keymap'])[0]; |
|
| 319 | + $relname .= '_'.array_values($data['keymap'])[0]; |
|
| 320 | 320 | } |
| 321 | 321 | $orig = $relname; |
| 322 | 322 | $cntr = 1; |
| 323 | 323 | while ($definition->hasRelation($relname) || $definition->getName() == $relname) { |
| 324 | - $relname = $orig . '_' . (++ $cntr); |
|
| 324 | + $relname = $orig.'_'.(++$cntr); |
|
| 325 | 325 | } |
| 326 | 326 | $definition->addRelation( |
| 327 | 327 | new TableRelation( |
@@ -349,23 +349,23 @@ discard block |
||
| 349 | 349 | "SELECT table_name FROM information_schema.tables where table_schema = ?", |
| 350 | 350 | [$this->connection['opts']['schema'] ?? $this->connection['name']] |
| 351 | 351 | )) |
| 352 | - ->map(function (array $v): array { |
|
| 352 | + ->map(function(array $v): array { |
|
| 353 | 353 | $new = []; |
| 354 | 354 | foreach ($v as $kk => $vv) { |
| 355 | 355 | $new[strtoupper($kk)] = $vv; |
| 356 | 356 | } |
| 357 | 357 | return $new; |
| 358 | 358 | }) |
| 359 | - ->mapKey(function (array $v): string { |
|
| 359 | + ->mapKey(function(array $v): string { |
|
| 360 | 360 | return strtolower($v['TABLE_NAME']); |
| 361 | 361 | }) |
| 362 | 362 | ->pluck('TABLE_NAME') |
| 363 | - ->map(function (string $v): Table { |
|
| 363 | + ->map(function(string $v): Table { |
|
| 364 | 364 | return $this->table($v)->toLowerCase(); |
| 365 | 365 | }) |
| 366 | 366 | ->toArray(); |
| 367 | 367 | foreach (array_keys($tables) as $k) { |
| 368 | - $tables[($this->connection['opts']['schema'] ?? $this->connection['name']) . '.' . $k] = &$tables[$k]; |
|
| 368 | + $tables[($this->connection['opts']['schema'] ?? $this->connection['name']).'.'.$k] = &$tables[$k]; |
|
| 369 | 369 | } |
| 370 | 370 | return $tables; |
| 371 | 371 | } |