@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | * |
| 22 | 22 | * @var array |
| 23 | 23 | */ |
| 24 | - private $types = [ //! arrays |
|
| 24 | + private $types = [//! arrays |
|
| 25 | 25 | 'Numbers' => ["smallint" => 5, "integer" => 10, "bigint" => 19, "boolean" => 1, |
| 26 | 26 | "numeric" => 0, "real" => 7, "double precision" => 16, "money" => 20], |
| 27 | 27 | 'Date and time' => ["date" => 13, "time" => 17, "timestamp" => 20, "timestamptz" => 21, "interval" => 0], |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | private $editFunctions = [[ |
| 71 | 71 | "char" => "md5", |
| 72 | 72 | "date|time" => "now", |
| 73 | - ],[ |
|
| 73 | + ], [ |
|
| 74 | 74 | // $this->numberRegex() => "+/-", |
| 75 | 75 | "date|time" => "+ interval/- interval", //! escape |
| 76 | 76 | "char|text" => "||", |
@@ -28,9 +28,7 @@ discard block |
||
| 28 | 28 | */ |
| 29 | 29 | public function limitToOne(string $table, string $query, string $where, string $separator = "\n") |
| 30 | 30 | { |
| 31 | - return (preg_match('~^INTO~', $query) ? $this->limit($query, $where, 1, 0, $separator) : |
|
| 32 | - " $query" . ($this->driver->isView($this->driver->tableStatusOrName($table)) ? $where : |
|
| 33 | - " WHERE ctid = (SELECT ctid FROM " . $this->table($table) . $where . $separator . "LIMIT 1)") |
|
| 31 | + return (preg_match('~^INTO~', $query) ? $this->limit($query, $where, 1, 0, $separator) : " $query" . ($this->driver->isView($this->driver->tableStatusOrName($table)) ? $where : " WHERE ctid = (SELECT ctid FROM " . $this->table($table) . $where . $separator . "LIMIT 1)") |
|
| 34 | 32 | ); |
| 35 | 33 | } |
| 36 | 34 | |
@@ -126,13 +124,13 @@ discard block |
||
| 126 | 124 | switch ($index->type) { |
| 127 | 125 | case 'UNIQUE': |
| 128 | 126 | $clauses[] = "CONSTRAINT " . $this->escapeId($index_name) . |
| 129 | - " UNIQUE (" . implode(', ', array_map(function ($column) { |
|
| 127 | + " UNIQUE (" . implode(', ', array_map(function($column) { |
|
| 130 | 128 | return $this->escapeId($column); |
| 131 | 129 | }, $index->columns)) . ")"; |
| 132 | 130 | break; |
| 133 | 131 | case 'PRIMARY': |
| 134 | 132 | $clauses[] = "CONSTRAINT " . $this->escapeId($index_name) . |
| 135 | - " PRIMARY KEY (" . implode(', ', array_map(function ($column) { |
|
| 133 | + " PRIMARY KEY (" . implode(', ', array_map(function($column) { |
|
| 136 | 134 | return $this->escapeId($column); |
| 137 | 135 | }, $index->columns)) . ")"; |
| 138 | 136 | break; |
@@ -179,8 +179,7 @@ discard block |
||
| 179 | 179 | $index = new IndexEntity(); |
| 180 | 180 | |
| 181 | 181 | $relname = $row["relname"]; |
| 182 | - $index->type = ($row["indispartial"] ? "INDEX" : |
|
| 183 | - ($row["indisprimary"] ? "PRIMARY" : ($row["indisunique"] ? "UNIQUE" : "INDEX"))); |
|
| 182 | + $index->type = ($row["indispartial"] ? "INDEX" : ($row["indisprimary"] ? "PRIMARY" : ($row["indisunique"] ? "UNIQUE" : "INDEX"))); |
|
| 184 | 183 | $index->columns = []; |
| 185 | 184 | foreach (explode(" ", $row["indkey"]) as $indkey) { |
| 186 | 185 | $index->columns[] = $columns[$indkey]; |
@@ -311,8 +310,7 @@ discard block |
||
| 311 | 310 | if ($val[0] != "INDEX") { |
| 312 | 311 | //! descending UNIQUE indexes results in syntax error |
| 313 | 312 | $create[] = ( |
| 314 | - $val[2] == "DROP" ? "\nDROP CONSTRAINT " . $this->driver->escapeId($val[1]) : |
|
| 315 | - "\nADD" . ($val[1] != "" ? " CONSTRAINT " . $this->driver->escapeId($val[1]) : "") . |
|
| 313 | + $val[2] == "DROP" ? "\nDROP CONSTRAINT " . $this->driver->escapeId($val[1]) : "\nADD" . ($val[1] != "" ? " CONSTRAINT " . $this->driver->escapeId($val[1]) : "") . |
|
| 316 | 314 | " $val[0] " . ($val[0] == "PRIMARY" ? "KEY " : "") . "(" . implode(", ", $val[2]) . ")" |
| 317 | 315 | ); |
| 318 | 316 | } elseif ($val[2] == "DROP") { |
@@ -78,7 +78,7 @@ |
||
| 78 | 78 | */ |
| 79 | 79 | public function truncateTables(array $tables) |
| 80 | 80 | { |
| 81 | - $this->driver->execute("TRUNCATE " . implode(", ", array_map(function ($table) { |
|
| 81 | + $this->driver->execute("TRUNCATE " . implode(", ", array_map(function($table) { |
|
| 82 | 82 | return $this->driver->table($table); |
| 83 | 83 | }, $tables))); |
| 84 | 84 | return true; |