@@ -44,7 +44,7 @@ |
||
44 | 44 | isset($this->connection['opts']) ? $this->connection['opts'] : [] |
45 | 45 | ); |
46 | 46 | } catch (\PDOException $e) { |
47 | - throw new DBException('Connect error: ' . $e->getMessage()); |
|
47 | + throw new DBException('Connect error: '.$e->getMessage()); |
|
48 | 48 | } |
49 | 49 | } |
50 | 50 | } |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | public function setPrimaryKey($column) : Table |
79 | 79 | { |
80 | 80 | if (!is_array($column)) { |
81 | - $column = [ $column ]; |
|
81 | + $column = [$column]; |
|
82 | 82 | } |
83 | 83 | $this->data['primary'] = $column; |
84 | 84 | return $this; |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | } |
166 | 166 | |
167 | 167 | if (!isset($name)) { |
168 | - $name = $toTable->getName() . '_' . implode('_', array_keys($keymap)); |
|
168 | + $name = $toTable->getName().'_'.implode('_', array_keys($keymap)); |
|
169 | 169 | } |
170 | 170 | $this->addRelation(new TableRelation( |
171 | 171 | $name, |
@@ -83,7 +83,7 @@ |
||
83 | 83 | } |
84 | 84 | } |
85 | 85 | if (!$this->statement->execute()) { |
86 | - throw new DBException('Prepared execute error: ' . $this->statement->error); |
|
86 | + throw new DBException('Prepared execute error: '.$this->statement->error); |
|
87 | 87 | } |
88 | 88 | return new Result($this->statement); |
89 | 89 | } |
@@ -74,7 +74,7 @@ |
||
74 | 74 | } |
75 | 75 | public function next() |
76 | 76 | { |
77 | - $this->fetched ++; |
|
77 | + $this->fetched++; |
|
78 | 78 | $temp = \odbc_fetch_row($this->statement); |
79 | 79 | if (!$temp) { |
80 | 80 | $this->last = false; |
@@ -18,6 +18,9 @@ |
||
18 | 18 | protected $fetched = -1; |
19 | 19 | protected $iid = null; |
20 | 20 | |
21 | + /** |
|
22 | + * @param resource $statement |
|
23 | + */ |
|
21 | 24 | public function __construct($statement, $data, $iid, $charIn = null, $charOut = null) |
22 | 25 | { |
23 | 26 | $this->statement = $statement; |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | $fields = []; |
71 | 71 | $exists = false; |
72 | 72 | foreach ($relation->table->getColumns() as $column) { |
73 | - $nm = $name . static::SEP . $column; |
|
73 | + $nm = $name.static::SEP.$column; |
|
74 | 74 | if (isset($this->aliases[$nm])) { |
75 | 75 | $nm = $this->aliases[$nm]; |
76 | 76 | } |
@@ -84,16 +84,16 @@ discard block |
||
84 | 84 | $parts = explode(static::SEP, $name); |
85 | 85 | $name = array_pop($parts); |
86 | 86 | if (!$exists && !count($parts) && !isset($temp[$name])) { |
87 | - $temp[$name] = $relation->many ? [ '___clean' => true ] : null; |
|
87 | + $temp[$name] = $relation->many ? ['___clean' => true] : null; |
|
88 | 88 | } |
89 | 89 | if ($exists) { |
90 | - $full = ''; |
|
90 | + $full = ''; |
|
91 | 91 | foreach ($parts as $item) { |
92 | - $full = $full ? $full . static::SEP . $item : $item; |
|
92 | + $full = $full ? $full.static::SEP.$item : $item; |
|
93 | 93 | $temp = &$temp[$item]; |
94 | 94 | $rpk = []; |
95 | 95 | foreach ($this->relations[$full][0]->table->getPrimaryKey() as $pkey) { |
96 | - $nm = $full . static::SEP . $pkey; |
|
96 | + $nm = $full.static::SEP.$pkey; |
|
97 | 97 | if (isset($this->aliases[$nm])) { |
98 | 98 | $nm = $this->aliases[$nm]; |
99 | 99 | } |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | $temp = &$temp[json_encode($rpk)]; |
103 | 103 | } |
104 | 104 | if (!isset($temp[$name])) { |
105 | - $temp[$name] = $relation->many ? [ '___clean' => true ] : null; |
|
105 | + $temp[$name] = $relation->many ? ['___clean' => true] : null; |
|
106 | 106 | } |
107 | 107 | $temp = &$temp[$name]; |
108 | 108 | if ($relation->many) { |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | return; |
161 | 161 | } |
162 | 162 | } |
163 | - $this->fetched ++; |
|
163 | + $this->fetched++; |
|
164 | 164 | while ($this->result->valid()) { |
165 | 165 | $row = $this->result->current(); |
166 | 166 | $pk = []; |
@@ -51,7 +51,7 @@ |
||
51 | 51 | $instance->setLength($data['length']); |
52 | 52 | } |
53 | 53 | if ($instance->getBasicType() === 'enum' && strpos($instance->getType(), 'enum(') === 0) { |
54 | - $temp = array_map(function ($v) { |
|
54 | + $temp = array_map(function($v) { |
|
55 | 55 | return str_replace("''", "'", $v); |
56 | 56 | }, explode("','", substr($instance->getType(), 6, -2))); |
57 | 57 | $instance->setValues($temp); |
@@ -24,28 +24,28 @@ |
||
24 | 24 | foreach ($data as $i => $v) { |
25 | 25 | switch (gettype($v)) { |
26 | 26 | case 'boolean': |
27 | - $this->statement->bindValue($i+1, $v, \PDO::PARAM_BOOL); |
|
27 | + $this->statement->bindValue($i + 1, $v, \PDO::PARAM_BOOL); |
|
28 | 28 | break; |
29 | 29 | case 'integer': |
30 | - $this->statement->bindValue($i+1, $v, \PDO::PARAM_INT); |
|
30 | + $this->statement->bindValue($i + 1, $v, \PDO::PARAM_INT); |
|
31 | 31 | break; |
32 | 32 | case 'NULL': |
33 | - $this->statement->bindValue($i+1, $v, \PDO::PARAM_NULL); |
|
33 | + $this->statement->bindValue($i + 1, $v, \PDO::PARAM_NULL); |
|
34 | 34 | break; |
35 | 35 | case 'double': |
36 | - $this->statement->bindValue($i+1, $v); |
|
36 | + $this->statement->bindValue($i + 1, $v); |
|
37 | 37 | break; |
38 | 38 | default: |
39 | 39 | // keep in mind oracle needs a transaction when inserting LOBs, aside from the specific syntax: |
40 | 40 | // INSERT INTO table (column, lobcolumn) VALUES (?, ?, EMPTY_BLOB()) RETURNING lobcolumn INTO ? |
41 | 41 | if (is_resource($v) && get_resource_type($v) === 'stream') { |
42 | - $this->statement->bindParam($i+1, $v, \PDO::PARAM_LOB); |
|
42 | + $this->statement->bindParam($i + 1, $v, \PDO::PARAM_LOB); |
|
43 | 43 | break; |
44 | 44 | } |
45 | 45 | if (!is_string($data[$i])) { |
46 | 46 | $data[$i] = serialize($data[$i]); |
47 | 47 | } |
48 | - $this->statement->bindValue($i+1, $v); |
|
48 | + $this->statement->bindValue($i + 1, $v); |
|
49 | 49 | break; |
50 | 50 | } |
51 | 51 | } |
@@ -90,7 +90,7 @@ |
||
90 | 90 | |
91 | 91 | public function begin() : bool |
92 | 92 | { |
93 | - return $this->transaction = true; |
|
93 | + return $this->transaction = true; |
|
94 | 94 | } |
95 | 95 | public function commit() : bool |
96 | 96 | { |
@@ -118,7 +118,7 @@ |
||
118 | 118 | } |
119 | 119 | return $new; |
120 | 120 | }) |
121 | - as $relation |
|
121 | + as $relation |
|
122 | 122 | ) { |
123 | 123 | $relations[$relation['CONSTRAINT_NAME']]['table'] = $relation['TABLE_NAME']; |
124 | 124 | $relations[$relation['CONSTRAINT_NAME']]['keymap'][$primary[(int)$relation['POSITION']-1]] = $relation['COLUMN_NAME']; |
@@ -138,17 +138,17 @@ discard block |
||
138 | 138 | $columns = Collection::from($this |
139 | 139 | ->query( |
140 | 140 | "SELECT * FROM all_tab_cols WHERE table_name = ? AND owner = ?", |
141 | - [ strtoupper($table), $this->name() ] |
|
141 | + [strtoupper($table), $this->name()] |
|
142 | 142 | )) |
143 | - ->map(function ($v) { |
|
143 | + ->map(function($v) { |
|
144 | 144 | $new = []; |
145 | 145 | foreach ($v as $kk => $vv) { |
146 | 146 | $new[strtoupper($kk)] = $vv; |
147 | 147 | } |
148 | 148 | return $new; |
149 | 149 | }) |
150 | - ->mapKey(function ($v) { return $v['COLUMN_NAME']; }) |
|
151 | - ->map(function ($v) { |
|
150 | + ->mapKey(function($v) { return $v['COLUMN_NAME']; }) |
|
151 | + ->map(function($v) { |
|
152 | 152 | $v['length'] = null; |
153 | 153 | if (!isset($v['DATA_TYPE'])) { |
154 | 154 | return $v; |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | default: |
161 | 161 | if (strpos($type, 'char') !== false && strpos($type, '(') !== false) { |
162 | 162 | // extract length from varchar |
163 | - $v['length'] = (int)explode(')', (explode('(', $type)[1] ?? ''))[0]; |
|
163 | + $v['length'] = (int) explode(')', (explode('(', $type)[1] ?? ''))[0]; |
|
164 | 164 | $v['length'] = $v['length'] > 0 ? $v['length'] : null; |
165 | 165 | } |
166 | 166 | break; |
@@ -176,9 +176,9 @@ discard block |
||
176 | 176 | ->query( |
177 | 177 | "SELECT constraint_name FROM all_constraints |
178 | 178 | WHERE table_name = ? AND constraint_type = ? AND owner = ?", |
179 | - [ strtoupper($table), 'P', $owner ] |
|
179 | + [strtoupper($table), 'P', $owner] |
|
180 | 180 | )) |
181 | - ->map(function ($v) { |
|
181 | + ->map(function($v) { |
|
182 | 182 | $new = []; |
183 | 183 | foreach ($v as $kk => $vv) { |
184 | 184 | $new[strtoupper($kk)] = $vv; |
@@ -193,9 +193,9 @@ discard block |
||
193 | 193 | ->query( |
194 | 194 | "SELECT column_name FROM all_cons_columns |
195 | 195 | WHERE table_name = ? AND constraint_name = ? AND owner = ?", |
196 | - [ strtoupper($table), $pkname, $owner ] |
|
196 | + [strtoupper($table), $pkname, $owner] |
|
197 | 197 | )) |
198 | - ->map(function ($v) { |
|
198 | + ->map(function($v) { |
|
199 | 199 | $new = []; |
200 | 200 | foreach ($v as $kk => $vv) { |
201 | 201 | $new[strtoupper($kk)] = $vv; |
@@ -222,9 +222,9 @@ discard block |
||
222 | 222 | LEFT JOIN all_cons_columns cc ON cc.OWNER = ac.OWNER AND cc.CONSTRAINT_NAME = ac.CONSTRAINT_NAME |
223 | 223 | WHERE ac.OWNER = ? AND ac.R_OWNER = ? AND ac.R_CONSTRAINT_NAME = ? AND ac.CONSTRAINT_TYPE = ? |
224 | 224 | ORDER BY cc.POSITION", |
225 | - [ $owner, $owner, $pkname, 'R' ] |
|
225 | + [$owner, $owner, $pkname, 'R'] |
|
226 | 226 | )) |
227 | - ->map(function ($v) { |
|
227 | + ->map(function($v) { |
|
228 | 228 | $new = []; |
229 | 229 | foreach ($v as $kk => $vv) { |
230 | 230 | $new[strtoupper($kk)] = $vv; |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | as $relation |
235 | 235 | ) { |
236 | 236 | $relations[$relation['CONSTRAINT_NAME']]['table'] = $relation['TABLE_NAME']; |
237 | - $relations[$relation['CONSTRAINT_NAME']]['keymap'][$primary[(int)$relation['POSITION']-1]] = $relation['COLUMN_NAME']; |
|
237 | + $relations[$relation['CONSTRAINT_NAME']]['keymap'][$primary[(int) $relation['POSITION'] - 1]] = $relation['COLUMN_NAME']; |
|
238 | 238 | } |
239 | 239 | foreach ($relations as $data) { |
240 | 240 | $rtable = $this->table($data['table'], true); |
@@ -258,9 +258,9 @@ discard block |
||
258 | 258 | ac.OWNER = ? AND ac.R_OWNER = ? AND ac.TABLE_NAME = ? AND ac.CONSTRAINT_TYPE = ? AND |
259 | 259 | cc.COLUMN_NAME IN (??) |
260 | 260 | ORDER BY POSITION", |
261 | - [ $owner, $owner, $data['table'], 'R', $columns ] |
|
261 | + [$owner, $owner, $data['table'], 'R', $columns] |
|
262 | 262 | )) |
263 | - ->map(function ($v) { |
|
263 | + ->map(function($v) { |
|
264 | 264 | $new = []; |
265 | 265 | foreach ($v as $kk => $vv) { |
266 | 266 | $new[strtoupper($kk)] = $vv; |
@@ -278,9 +278,9 @@ discard block |
||
278 | 278 | $rcolumns = Collection::from($this |
279 | 279 | ->query( |
280 | 280 | "SELECT COLUMN_NAME FROM all_cons_columns WHERE OWNER = ? AND CONSTRAINT_NAME = ? ORDER BY POSITION", |
281 | - [ $owner, current($foreign['keymap']) ] |
|
281 | + [$owner, current($foreign['keymap'])] |
|
282 | 282 | )) |
283 | - ->map(function ($v) { |
|
283 | + ->map(function($v) { |
|
284 | 284 | $new = []; |
285 | 285 | foreach ($v as $kk => $vv) { |
286 | 286 | $new[strtoupper($kk)] = $vv; |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | $relname = $foreign['table']; |
296 | 296 | $cntr = 1; |
297 | 297 | while ($definition->hasRelation($relname) || $definition->getName() == $relname) { |
298 | - $relname = $foreign['table'] . '_' . (++ $cntr); |
|
298 | + $relname = $foreign['table'].'_'.(++$cntr); |
|
299 | 299 | } |
300 | 300 | $definition->addRelation( |
301 | 301 | new TableRelation( |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | $relname = $data['table']; |
312 | 312 | $cntr = 1; |
313 | 313 | while ($definition->hasRelation($relname) || $definition->getName() == $relname) { |
314 | - $relname = $data['table'] . '_' . (++ $cntr); |
|
314 | + $relname = $data['table'].'_'.(++$cntr); |
|
315 | 315 | } |
316 | 316 | $definition->addRelation( |
317 | 317 | new TableRelation( |
@@ -335,9 +335,9 @@ discard block |
||
335 | 335 | LEFT JOIN all_cons_columns cc ON cc.OWNER = ac.OWNER AND cc.CONSTRAINT_NAME = ac.CONSTRAINT_NAME |
336 | 336 | WHERE ac.OWNER = ? AND ac.R_OWNER = ? AND ac.TABLE_NAME = ? AND ac.CONSTRAINT_TYPE = ? |
337 | 337 | ORDER BY cc.POSITION", |
338 | - [ $owner, $owner, strtoupper($table), 'R' ] |
|
338 | + [$owner, $owner, strtoupper($table), 'R'] |
|
339 | 339 | )) |
340 | - ->map(function ($v) { |
|
340 | + ->map(function($v) { |
|
341 | 341 | $new = []; |
342 | 342 | foreach ($v as $kk => $vv) { |
343 | 343 | $new[strtoupper($kk)] = $vv; |
@@ -353,9 +353,9 @@ discard block |
||
353 | 353 | $rcolumns = Collection::from($this |
354 | 354 | ->query( |
355 | 355 | "SELECT COLUMN_NAME FROM all_cons_columns WHERE OWNER = ? AND CONSTRAINT_NAME = ? ORDER BY POSITION", |
356 | - [ $owner, current($data['keymap']) ] |
|
356 | + [$owner, current($data['keymap'])] |
|
357 | 357 | )) |
358 | - ->map(function ($v) { |
|
358 | + ->map(function($v) { |
|
359 | 359 | $new = []; |
360 | 360 | foreach ($v as $kk => $vv) { |
361 | 361 | $new[strtoupper($kk)] = $vv; |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | $relname = $data['table']; |
371 | 371 | $cntr = 1; |
372 | 372 | while ($definition->hasRelation($relname) || $definition->getName() == $relname) { |
373 | - $relname = $data['table'] . '_' . (++ $cntr); |
|
373 | + $relname = $data['table'].'_'.(++$cntr); |
|
374 | 374 | } |
375 | 375 | $definition->addRelation( |
376 | 376 | new TableRelation( |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | "SELECT TABLE_NAME FROM ALL_TABLES where OWNER = ?", |
392 | 392 | [$this->connection['name']] |
393 | 393 | )) |
394 | - ->map(function ($v) { |
|
394 | + ->map(function($v) { |
|
395 | 395 | $new = []; |
396 | 396 | foreach ($v as $kk => $vv) { |
397 | 397 | $new[strtoupper($kk)] = $vv; |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | return $new; |
400 | 400 | }) |
401 | 401 | ->pluck('TABLE_NAME') |
402 | - ->map(function ($v) { |
|
402 | + ->map(function($v) { |
|
403 | 403 | return $this->table($v); |
404 | 404 | }) |
405 | 405 | ->toArray(); |