@@ -52,7 +52,7 @@ |
||
| 52 | 52 | $this->connect(); |
| 53 | 53 | $statement = \ibase_prepare($this->transaction !== null ? $this->transaction : $this->lnk, $sql); |
| 54 | 54 | if ($statement === false) { |
| 55 | - throw new DBException('Prepare error: ' . \ibase_errmsg()); |
|
| 55 | + throw new DBException('Prepare error: '.\ibase_errmsg()); |
|
| 56 | 56 | } |
| 57 | 57 | return new Statement( |
| 58 | 58 | $statement, |
@@ -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 | continue; |
| 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 | } |
@@ -55,7 +55,7 @@ |
||
| 55 | 55 | } |
| 56 | 56 | public function next() |
| 57 | 57 | { |
| 58 | - $this->fetched ++; |
|
| 58 | + $this->fetched++; |
|
| 59 | 59 | $this->last = $this->statement->fetch(\PDO::FETCH_ASSOC); |
| 60 | 60 | } |
| 61 | 61 | public function valid() |
@@ -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 | } |
@@ -62,11 +62,11 @@ discard block |
||
| 62 | 62 | $fields = []; |
| 63 | 63 | $exists = false; |
| 64 | 64 | foreach ($relation->table->getColumns() as $column) { |
| 65 | - $fields[$column] = $row[$name . '___' . $column]; |
|
| 66 | - if (!$exists && $row[$name . '___' . $column] !== null) { |
|
| 65 | + $fields[$column] = $row[$name.'___'.$column]; |
|
| 66 | + if (!$exists && $row[$name.'___'.$column] !== null) { |
|
| 67 | 67 | $exists = true; |
| 68 | 68 | } |
| 69 | - unset($result[$name . '___' . $column]); |
|
| 69 | + unset($result[$name.'___'.$column]); |
|
| 70 | 70 | } |
| 71 | 71 | if ($exists) { |
| 72 | 72 | if ($relation->many) { |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | return; |
| 114 | 114 | } |
| 115 | 115 | } |
| 116 | - $this->fetched ++; |
|
| 116 | + $this->fetched++; |
|
| 117 | 117 | while ($this->result->valid()) { |
| 118 | 118 | $row = $this->result->current(); |
| 119 | 119 | $pk = []; |
@@ -47,7 +47,7 @@ |
||
| 47 | 47 | $instance->setDefault($data['default']); |
| 48 | 48 | } |
| 49 | 49 | if ($instance->getBasicType() === 'enum' && strpos($instance->getType(), 'enum(') === 0) { |
| 50 | - $temp = array_map(function ($v) { |
|
| 50 | + $temp = array_map(function($v) { |
|
| 51 | 51 | return str_replace("''", "'", $v); |
| 52 | 52 | }, explode("','", substr($instance->getType(), 6, -2))); |
| 53 | 53 | $instance->setValues($temp); |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | /** |
| 43 | 43 | * @var int[] |
| 44 | 44 | */ |
| 45 | - protected $li_of = [0,0]; |
|
| 45 | + protected $li_of = [0, 0]; |
|
| 46 | 46 | protected $fields = []; |
| 47 | 47 | /** |
| 48 | 48 | * @var array |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | public function __construct(DBInterface $db, $table) |
| 62 | 62 | { |
| 63 | 63 | $this->db = $db; |
| 64 | - $this->definition = $table instanceof Table ? $table : $this->db->definition((string)$table); |
|
| 64 | + $this->definition = $table instanceof Table ? $table : $this->db->definition((string) $table); |
|
| 65 | 65 | $this->columns($this->definition->getColumns()); |
| 66 | 66 | } |
| 67 | 67 | public function __clone() |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | { |
| 82 | 82 | $column = explode('.', $column, 2); |
| 83 | 83 | if (count($column) === 1) { |
| 84 | - $column = [ $this->definition->getName(), $column[0] ]; |
|
| 84 | + $column = [$this->definition->getName(), $column[0]]; |
|
| 85 | 85 | } |
| 86 | 86 | if ($column[0] === $this->definition->getName()) { |
| 87 | 87 | $col = $this->definition->getColumn($column[1]); |
@@ -100,10 +100,10 @@ discard block |
||
| 100 | 100 | throw new DBException('Invalid column name in related table'); |
| 101 | 101 | } |
| 102 | 102 | } else { |
| 103 | - throw new DBException('Invalid foreign table name: ' . implode(',', $column)); |
|
| 103 | + throw new DBException('Invalid foreign table name: '.implode(',', $column)); |
|
| 104 | 104 | } |
| 105 | 105 | } |
| 106 | - return [ 'name' => implode('.', $column), 'data' => $col ]; |
|
| 106 | + return ['name' => implode('.', $column), 'data' => $col]; |
|
| 107 | 107 | } |
| 108 | 108 | protected function normalizeValue(TableColumn $col, $value) |
| 109 | 109 | { |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | } |
| 143 | 143 | return $value; |
| 144 | 144 | case 'int': |
| 145 | - return (int)$value; |
|
| 145 | + return (int) $value; |
|
| 146 | 146 | default: |
| 147 | 147 | return $value; |
| 148 | 148 | } |
@@ -157,12 +157,12 @@ discard block |
||
| 157 | 157 | { |
| 158 | 158 | list($name, $column) = array_values($this->getColumn($column)); |
| 159 | 159 | if (is_null($value)) { |
| 160 | - return $this->where($name . ' IS NULL'); |
|
| 160 | + return $this->where($name.' IS NULL'); |
|
| 161 | 161 | } |
| 162 | 162 | if (!is_array($value)) { |
| 163 | 163 | return $this->where( |
| 164 | - $name . ' = ?', |
|
| 165 | - [ $this->normalizeValue($column, $value) ] |
|
| 164 | + $name.' = ?', |
|
| 165 | + [$this->normalizeValue($column, $value)] |
|
| 166 | 166 | ); |
| 167 | 167 | } |
| 168 | 168 | if (isset($value['beg']) && isset($value['end'])) { |
@@ -175,8 +175,8 @@ discard block |
||
| 175 | 175 | ); |
| 176 | 176 | } |
| 177 | 177 | return $this->where( |
| 178 | - $name . ' IN (??)', |
|
| 179 | - [ array_map(function ($v) use ($column) { return $this->normalizeValue($column, $v); }, $value) ] |
|
| 178 | + $name.' IN (??)', |
|
| 179 | + [array_map(function($v) use ($column) { return $this->normalizeValue($column, $v); }, $value)] |
|
| 180 | 180 | ); |
| 181 | 181 | } |
| 182 | 182 | /** |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | */ |
| 188 | 188 | public function sort(string $column, bool $desc = false) : TableQuery |
| 189 | 189 | { |
| 190 | - return $this->order($this->getColumn($column)['name'] . ' ' . ($desc ? 'DESC' : 'ASC')); |
|
| 190 | + return $this->order($this->getColumn($column)['name'].' '.($desc ? 'DESC' : 'ASC')); |
|
| 191 | 191 | } |
| 192 | 192 | /** |
| 193 | 193 | * Group by a column (or columns) |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | public function group($column) : TableQuery |
| 198 | 198 | { |
| 199 | 199 | if (!is_array($column)) { |
| 200 | - $column = [ $column ]; |
|
| 200 | + $column = [$column]; |
|
| 201 | 201 | } |
| 202 | 202 | foreach ($column as $k => $v) { |
| 203 | 203 | $column[$k] = $this->getColumn($v)['name']; |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | $this->withr = []; |
| 239 | 239 | $this->order = []; |
| 240 | 240 | $this->having = []; |
| 241 | - $this->li_of = [0,0]; |
|
| 241 | + $this->li_of = [0, 0]; |
|
| 242 | 242 | $this->qiterator = null; |
| 243 | 243 | return $this; |
| 244 | 244 | } |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | public function groupBy(string $sql, array $params = []) : TableQuery |
| 252 | 252 | { |
| 253 | 253 | $this->qiterator = null; |
| 254 | - $this->group = [ $sql, $params ]; |
|
| 254 | + $this->group = [$sql, $params]; |
|
| 255 | 255 | return $this; |
| 256 | 256 | } |
| 257 | 257 | /** |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | */ |
| 265 | 265 | public function join($table, array $fields, string $name = null, bool $multiple = true) |
| 266 | 266 | { |
| 267 | - $table = $table instanceof Table ? $table : $this->db->definition((string)$table); |
|
| 267 | + $table = $table instanceof Table ? $table : $this->db->definition((string) $table); |
|
| 268 | 268 | $name = $name ?? $table->getName(); |
| 269 | 269 | if (isset($this->joins[$name]) || $this->definition->hasRelation($name)) { |
| 270 | 270 | throw new DBException('Alias / table name already in use'); |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | foreach ($fields as $k => $v) { |
| 274 | 274 | $k = explode('.', $k, 2); |
| 275 | 275 | $k = count($k) == 2 ? $k[1] : $k[0]; |
| 276 | - $this->joins[$name]->keymap[$this->getColumn($name . '.' . $k)['name']] = $this->getColumn($v)['name']; |
|
| 276 | + $this->joins[$name]->keymap[$this->getColumn($name.'.'.$k)['name']] = $this->getColumn($v)['name']; |
|
| 277 | 277 | } |
| 278 | 278 | return $this; |
| 279 | 279 | } |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | public function where(string $sql, array $params = []) : TableQuery |
| 287 | 287 | { |
| 288 | 288 | $this->qiterator = null; |
| 289 | - $this->where[] = [ $sql, $params ]; |
|
| 289 | + $this->where[] = [$sql, $params]; |
|
| 290 | 290 | return $this; |
| 291 | 291 | } |
| 292 | 292 | /** |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | public function having(string $sql, array $params = []) : TableQuery |
| 299 | 299 | { |
| 300 | 300 | $this->qiterator = null; |
| 301 | - $this->having[] = [ $sql, $params ]; |
|
| 301 | + $this->having[] = [$sql, $params]; |
|
| 302 | 302 | return $this; |
| 303 | 303 | } |
| 304 | 304 | /** |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | public function order(string $sql, array $params = []) : TableQuery |
| 311 | 311 | { |
| 312 | 312 | $this->qiterator = null; |
| 313 | - $this->order = [ $sql, $params ]; |
|
| 313 | + $this->order = [$sql, $params]; |
|
| 314 | 314 | return $this; |
| 315 | 315 | } |
| 316 | 316 | /** |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | public function limit(int $limit, int $offset = 0) : TableQuery |
| 323 | 323 | { |
| 324 | 324 | $this->qiterator = null; |
| 325 | - $this->li_of = [ $limit, $offset ]; |
|
| 325 | + $this->li_of = [$limit, $offset]; |
|
| 326 | 326 | return $this; |
| 327 | 327 | } |
| 328 | 328 | /** |
@@ -339,22 +339,22 @@ discard block |
||
| 339 | 339 | $relations = $this->withr; |
| 340 | 340 | foreach ($this->definition->getRelations() as $k => $v) { |
| 341 | 341 | foreach ($this->where as $vv) { |
| 342 | - if (strpos($vv[0], $k . '.') !== false) { |
|
| 342 | + if (strpos($vv[0], $k.'.') !== false) { |
|
| 343 | 343 | $relations[] = $k; |
| 344 | 344 | } |
| 345 | 345 | } |
| 346 | - if (isset($this->order[0]) && strpos($this->order[0], $k . '.') !== false) { |
|
| 346 | + if (isset($this->order[0]) && strpos($this->order[0], $k.'.') !== false) { |
|
| 347 | 347 | $relations[] = $k; |
| 348 | 348 | } |
| 349 | 349 | } |
| 350 | 350 | |
| 351 | 351 | foreach ($this->joins as $k => $v) { |
| 352 | - $sql .= ($v->many ? 'LEFT ' : '' ) . 'JOIN '.$v->table->getName().' '.$k.' ON '; |
|
| 352 | + $sql .= ($v->many ? 'LEFT ' : '').'JOIN '.$v->table->getName().' '.$k.' ON '; |
|
| 353 | 353 | $tmp = []; |
| 354 | 354 | foreach ($v->keymap as $kk => $vv) { |
| 355 | 355 | $tmp[] = $kk.' = '.$vv; |
| 356 | 356 | } |
| 357 | - $sql .= implode(' AND ', $tmp) . ' '; |
|
| 357 | + $sql .= implode(' AND ', $tmp).' '; |
|
| 358 | 358 | } |
| 359 | 359 | foreach (array_unique($relations) as $k) { |
| 360 | 360 | $v = $this->definition->getRelation($k); |
@@ -364,13 +364,13 @@ discard block |
||
| 364 | 364 | foreach ($v->keymap as $kk => $vv) { |
| 365 | 365 | $tmp[] = $table.'.'.$kk.' = '.$k.'_pivot.'.$vv.' '; |
| 366 | 366 | } |
| 367 | - $sql .= implode(' AND ', $tmp) . ' '; |
|
| 367 | + $sql .= implode(' AND ', $tmp).' '; |
|
| 368 | 368 | $sql .= 'LEFT JOIN '.$v->table->getName().' '.$k.' ON '; |
| 369 | 369 | $tmp = []; |
| 370 | 370 | foreach ($v->pivot_keymap as $kk => $vv) { |
| 371 | 371 | $tmp[] = $k.'.'.$vv.' = '.$k.'_pivot.'.$kk.' '; |
| 372 | 372 | } |
| 373 | - $sql .= implode(' AND ', $tmp) . ' '; |
|
| 373 | + $sql .= implode(' AND ', $tmp).' '; |
|
| 374 | 374 | } else { |
| 375 | 375 | $sql .= 'LEFT JOIN '.$v->table->getName().' '.$k.' ON '; |
| 376 | 376 | $tmp = []; |
@@ -378,30 +378,30 @@ discard block |
||
| 378 | 378 | $tmp[] = $table.'.'.$kk.' = '.$k.'.'.$vv.' '; |
| 379 | 379 | } |
| 380 | 380 | if ($v->sql) { |
| 381 | - $tmp[] = $v->sql . ' '; |
|
| 381 | + $tmp[] = $v->sql.' '; |
|
| 382 | 382 | $par = array_merge($par, $v->par ?? []); |
| 383 | 383 | } |
| 384 | - $sql .= implode(' AND ', $tmp) . ' '; |
|
| 384 | + $sql .= implode(' AND ', $tmp).' '; |
|
| 385 | 385 | } |
| 386 | 386 | } |
| 387 | 387 | if (count($this->where)) { |
| 388 | 388 | $sql .= 'WHERE '; |
| 389 | 389 | $tmp = []; |
| 390 | 390 | foreach ($this->where as $v) { |
| 391 | - $tmp[] = '(' . $v[0] . ')'; |
|
| 391 | + $tmp[] = '('.$v[0].')'; |
|
| 392 | 392 | $par = array_merge($par, $v[1]); |
| 393 | 393 | } |
| 394 | 394 | $sql .= implode(' AND ', $tmp).' '; |
| 395 | 395 | } |
| 396 | 396 | if (count($this->group)) { |
| 397 | - $sql .= 'GROUP BY ' . $this->group[0] . ' '; |
|
| 397 | + $sql .= 'GROUP BY '.$this->group[0].' '; |
|
| 398 | 398 | $par = array_merge($par, $this->group[1]); |
| 399 | 399 | } |
| 400 | 400 | if (count($this->having)) { |
| 401 | 401 | $sql .= 'HAVING '; |
| 402 | 402 | $tmp = []; |
| 403 | 403 | foreach ($this->having as $v) { |
| 404 | - $tmp[] = '(' . $v[0] . ')'; |
|
| 404 | + $tmp[] = '('.$v[0].')'; |
|
| 405 | 405 | $par = array_merge($par, $v[1]); |
| 406 | 406 | } |
| 407 | 407 | $sql .= implode(' AND ', $tmp).' '; |
@@ -432,7 +432,7 @@ discard block |
||
| 432 | 432 | throw new DBException('Invalid foreign table name'); |
| 433 | 433 | } |
| 434 | 434 | foreach ($cols as $col) { |
| 435 | - $fields[] = $table . '.' . $col; |
|
| 435 | + $fields[] = $table.'.'.$col; |
|
| 436 | 436 | } |
| 437 | 437 | unset($fields[$k]); |
| 438 | 438 | } |
@@ -472,37 +472,37 @@ discard block |
||
| 472 | 472 | $relations = $this->withr; |
| 473 | 473 | foreach ($this->definition->getRelations() as $k => $v) { |
| 474 | 474 | foreach ($this->fields as $field) { |
| 475 | - if (strpos($field, $k . '.') === 0) { |
|
| 475 | + if (strpos($field, $k.'.') === 0) { |
|
| 476 | 476 | $relations[] = $k; |
| 477 | 477 | } |
| 478 | 478 | } |
| 479 | 479 | foreach ($this->where as $v) { |
| 480 | - if (strpos($v[0], $k . '.') !== false) { |
|
| 480 | + if (strpos($v[0], $k.'.') !== false) { |
|
| 481 | 481 | $relations[] = $k; |
| 482 | 482 | } |
| 483 | 483 | } |
| 484 | - if (isset($this->order[0]) && strpos($this->order[0], $k . '.') !== false) { |
|
| 484 | + if (isset($this->order[0]) && strpos($this->order[0], $k.'.') !== false) { |
|
| 485 | 485 | $relations[] = $k; |
| 486 | 486 | } |
| 487 | 487 | } |
| 488 | 488 | $select = []; |
| 489 | 489 | foreach ($this->fields as $k => $field) { |
| 490 | - $select[] = $field . (!is_numeric($k) ? ' ' . $k : ''); |
|
| 490 | + $select[] = $field.(!is_numeric($k) ? ' '.$k : ''); |
|
| 491 | 491 | } |
| 492 | 492 | foreach ($this->withr as $relation) { |
| 493 | 493 | foreach ($this->definition->getRelation($relation)->table->getColumns() as $column) { |
| 494 | - $select[] = $relation . '.' . $column . ' ' . $relation . '___' . $column; |
|
| 494 | + $select[] = $relation.'.'.$column.' '.$relation.'___'.$column; |
|
| 495 | 495 | } |
| 496 | 496 | } |
| 497 | 497 | $sql = 'SELECT '.implode(', ', $select).' FROM '.$table.' '; |
| 498 | 498 | $par = []; |
| 499 | 499 | foreach ($this->joins as $k => $v) { |
| 500 | - $sql .= ($v->many ? 'LEFT ' : '' ) . 'JOIN '.$v->table->getName().' '.$k.' ON '; |
|
| 500 | + $sql .= ($v->many ? 'LEFT ' : '').'JOIN '.$v->table->getName().' '.$k.' ON '; |
|
| 501 | 501 | $tmp = []; |
| 502 | 502 | foreach ($v->keymap as $kk => $vv) { |
| 503 | 503 | $tmp[] = $kk.' = '.$vv; |
| 504 | 504 | } |
| 505 | - $sql .= implode(' AND ', $tmp) . ' '; |
|
| 505 | + $sql .= implode(' AND ', $tmp).' '; |
|
| 506 | 506 | } |
| 507 | 507 | foreach (array_unique($relations) as $relation) { |
| 508 | 508 | $v = $this->definition->getRelation($relation); |
@@ -512,13 +512,13 @@ discard block |
||
| 512 | 512 | foreach ($v->keymap as $kk => $vv) { |
| 513 | 513 | $tmp[] = $table.'.'.$kk.' = '.$relation.'_pivot.'.$vv.' '; |
| 514 | 514 | } |
| 515 | - $sql .= implode(' AND ', $tmp) . ' '; |
|
| 515 | + $sql .= implode(' AND ', $tmp).' '; |
|
| 516 | 516 | $sql .= 'LEFT JOIN '.$v->table->getName().' '.$relation.' ON '; |
| 517 | 517 | $tmp = []; |
| 518 | 518 | foreach ($v->pivot_keymap as $kk => $vv) { |
| 519 | 519 | $tmp[] = $relation.'.'.$vv.' = '.$relation.'_pivot.'.$kk.' '; |
| 520 | 520 | } |
| 521 | - $sql .= implode(' AND ', $tmp) . ' '; |
|
| 521 | + $sql .= implode(' AND ', $tmp).' '; |
|
| 522 | 522 | } else { |
| 523 | 523 | $sql .= 'LEFT JOIN '.$v->table->getName().' '.$relation.' ON '; |
| 524 | 524 | $tmp = []; |
@@ -526,30 +526,30 @@ discard block |
||
| 526 | 526 | $tmp[] = $table.'.'.$kk.' = '.$relation.'.'.$vv.' '; |
| 527 | 527 | } |
| 528 | 528 | if ($v->sql) { |
| 529 | - $tmp[] = $v->sql . ' '; |
|
| 529 | + $tmp[] = $v->sql.' '; |
|
| 530 | 530 | $par = array_merge($par, $v->par ?? []); |
| 531 | 531 | } |
| 532 | - $sql .= implode(' AND ', $tmp) . ' '; |
|
| 532 | + $sql .= implode(' AND ', $tmp).' '; |
|
| 533 | 533 | } |
| 534 | 534 | } |
| 535 | 535 | if (count($this->where)) { |
| 536 | 536 | $sql .= 'WHERE '; |
| 537 | 537 | $tmp = []; |
| 538 | 538 | foreach ($this->where as $v) { |
| 539 | - $tmp[] = '(' . $v[0] . ')'; |
|
| 539 | + $tmp[] = '('.$v[0].')'; |
|
| 540 | 540 | $par = array_merge($par, $v[1]); |
| 541 | 541 | } |
| 542 | 542 | $sql .= implode(' AND ', $tmp).' '; |
| 543 | 543 | } |
| 544 | 544 | if (count($this->group)) { |
| 545 | - $sql .= 'GROUP BY ' . $this->group[0] . ' '; |
|
| 545 | + $sql .= 'GROUP BY '.$this->group[0].' '; |
|
| 546 | 546 | $par = array_merge($par, $this->group[1]); |
| 547 | 547 | } |
| 548 | 548 | if (count($this->having)) { |
| 549 | 549 | $sql .= 'HAVING '; |
| 550 | 550 | $tmp = []; |
| 551 | 551 | foreach ($this->having as $v) { |
| 552 | - $tmp[] = '(' . $v[0] . ')'; |
|
| 552 | + $tmp[] = '('.$v[0].')'; |
|
| 553 | 553 | $par = array_merge($par, $v[1]); |
| 554 | 554 | } |
| 555 | 555 | $sql .= implode(' AND ', $tmp).' '; |
@@ -558,36 +558,36 @@ discard block |
||
| 558 | 558 | // $sql .= 'GROUP BY '.$table.'.'.implode(', '.$table.'.', $primary).' '; |
| 559 | 559 | //} |
| 560 | 560 | if (count($this->order)) { |
| 561 | - $sql .= 'ORDER BY ' . $this->order[0] . ' '; |
|
| 561 | + $sql .= 'ORDER BY '.$this->order[0].' '; |
|
| 562 | 562 | $par = array_merge($par, $this->order[1]); |
| 563 | 563 | } |
| 564 | 564 | $porder = []; |
| 565 | 565 | foreach ($primary as $field) { |
| 566 | 566 | $porder[] = $this->getColumn($field)['name']; |
| 567 | 567 | } |
| 568 | - $sql .= (count($this->order) ? ', ' : 'ORDER BY ') . implode(', ', $porder) . ' '; |
|
| 568 | + $sql .= (count($this->order) ? ', ' : 'ORDER BY ').implode(', ', $porder).' '; |
|
| 569 | 569 | |
| 570 | 570 | if ($this->li_of[0]) { |
| 571 | 571 | if ($this->db->driver() === 'oracle') { |
| 572 | - if ((int)($this->db->settings()->options['version'] ?? 0) >= 12) { |
|
| 573 | - $sql .= 'OFFSET ' . $this->li_of[1] . ' ROWS FETCH NEXT ' . $this->li_of[0] . ' ROWS ONLY'; |
|
| 572 | + if ((int) ($this->db->settings()->options['version'] ?? 0) >= 12) { |
|
| 573 | + $sql .= 'OFFSET '.$this->li_of[1].' ROWS FETCH NEXT '.$this->li_of[0].' ROWS ONLY'; |
|
| 574 | 574 | } else { |
| 575 | - $f = array_map(function ($v) { |
|
| 575 | + $f = array_map(function($v) { |
|
| 576 | 576 | $v = explode(' ', trim($v), 2); |
| 577 | 577 | if (count($v) === 2) { return $v[1]; } |
| 578 | 578 | $v = explode('.', $v[0], 2); |
| 579 | 579 | return count($v) === 2 ? $v[1] : $v[0]; |
| 580 | 580 | }, $select); |
| 581 | - $sql = "SELECT " . implode(', ', $f) . " |
|
| 581 | + $sql = "SELECT ".implode(', ', $f)." |
|
| 582 | 582 | FROM ( |
| 583 | 583 | SELECT tbl__.*, rownum rnum__ FROM ( |
| 584 | - " . $sql . " |
|
| 584 | + " . $sql." |
|
| 585 | 585 | ) tbl__ |
| 586 | - WHERE rownum <= " . ($this->li_of[0] + $this->li_of[1]) . " |
|
| 586 | + WHERE rownum <= " . ($this->li_of[0] + $this->li_of[1])." |
|
| 587 | 587 | ) WHERE rnum__ > " . $this->li_of[1]; |
| 588 | 588 | } |
| 589 | 589 | } else { |
| 590 | - $sql .= 'LIMIT ' . $this->li_of[0] . ' OFFSET ' . $this->li_of[1]; |
|
| 590 | + $sql .= 'LIMIT '.$this->li_of[0].' OFFSET '.$this->li_of[1]; |
|
| 591 | 591 | } |
| 592 | 592 | } |
| 593 | 593 | return $this->qiterator = new TableQueryIterator( |
@@ -595,7 +595,7 @@ discard block |
||
| 595 | 595 | $this->definition->getPrimaryKey(), |
| 596 | 596 | array_combine( |
| 597 | 597 | $this->withr, |
| 598 | - array_map(function ($relation) { |
|
| 598 | + array_map(function($relation) { |
|
| 599 | 599 | return $this->definition->getRelation($relation); |
| 600 | 600 | }, $this->withr) |
| 601 | 601 | ) |
@@ -642,7 +642,7 @@ discard block |
||
| 642 | 642 | $ret[$k] = str_repeat(' ', 255); |
| 643 | 643 | $par[] = &$ret[$k]; |
| 644 | 644 | } |
| 645 | - $sql .= ' RETURNING ' . implode(',', $primary) . ' INTO ' . implode(',', array_fill(0, count($primary), '?')); |
|
| 645 | + $sql .= ' RETURNING '.implode(',', $primary).' INTO '.implode(',', array_fill(0, count($primary), '?')); |
|
| 646 | 646 | $this->db->query($sql, $par); |
| 647 | 647 | return $ret; |
| 648 | 648 | } else { |
@@ -674,7 +674,7 @@ discard block |
||
| 674 | 674 | } |
| 675 | 675 | $sql = 'UPDATE '.$table.' SET '; |
| 676 | 676 | $par = []; |
| 677 | - $sql .= implode(', ', array_map(function ($v) { return $v . ' = ?'; }, array_keys($update))) . ' '; |
|
| 677 | + $sql .= implode(', ', array_map(function($v) { return $v.' = ?'; }, array_keys($update))).' '; |
|
| 678 | 678 | $par = array_merge($par, array_values($update)); |
| 679 | 679 | if (count($this->where)) { |
| 680 | 680 | $sql .= 'WHERE '; |
@@ -683,7 +683,7 @@ discard block |
||
| 683 | 683 | $tmp[] = $v[0]; |
| 684 | 684 | $par = array_merge($par, $v[1]); |
| 685 | 685 | } |
| 686 | - $sql .= implode(' AND ', $tmp) . ' '; |
|
| 686 | + $sql .= implode(' AND ', $tmp).' '; |
|
| 687 | 687 | } |
| 688 | 688 | if (count($this->order)) { |
| 689 | 689 | $sql .= $this->order[0]; |
@@ -707,7 +707,7 @@ discard block |
||
| 707 | 707 | $tmp[] = $v[0]; |
| 708 | 708 | $par = array_merge($par, $v[1]); |
| 709 | 709 | } |
| 710 | - $sql .= implode(' AND ', $tmp) . ' '; |
|
| 710 | + $sql .= implode(' AND ', $tmp).' '; |
|
| 711 | 711 | } |
| 712 | 712 | if (count($this->order)) { |
| 713 | 713 | $sql .= $this->order[0]; |
@@ -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, |