@@ -117,7 +117,6 @@ discard block |
||
| 117 | 117 | /** |
| 118 | 118 | * Run a query (prepare & execute). |
| 119 | 119 | * @param string $sql SQL query |
| 120 | - * @param array $data parameters (optional) |
|
| 121 | 120 | * @return ResultInterface the result of the execution |
| 122 | 121 | */ |
| 123 | 122 | public function query(string $sql, $par = null) : ResultInterface |
@@ -170,7 +169,6 @@ discard block |
||
| 170 | 169 | * Run a SELECT query and get a single row |
| 171 | 170 | * @param string $sql SQL query |
| 172 | 171 | * @param array $par parameters |
| 173 | - * @param callable $keys an optional mutator to pass each row's keys through (the column names) |
|
| 174 | 172 | * @param bool $opti if a single column is returned - do not use an array wrapper (defaults to `true`) |
| 175 | 173 | * @return Collection the result of the execution |
| 176 | 174 | */ |
@@ -184,7 +182,6 @@ discard block |
||
| 184 | 182 | * @param array $par parameters |
| 185 | 183 | * @param string $key column name to use as the array index |
| 186 | 184 | * @param bool $skip do not include the column used as index in the value (defaults to `false`) |
| 187 | - * @param callable $keys an optional mutator to pass each row's keys through (the column names) |
|
| 188 | 185 | * @param bool $opti if a single column is returned - do not use an array wrapper (defaults to `true`) |
| 189 | 186 | * @return Collection the result of the execution |
| 190 | 187 | */ |
@@ -73,8 +73,7 @@ discard block |
||
| 73 | 73 | } |
| 74 | 74 | $connection['name'] = $connectionString; |
| 75 | 75 | $connection['type'] = isset($aliases[$connection['type']]) ? |
| 76 | - $aliases[$connection['type']] : |
|
| 77 | - $connection['type']; |
|
| 76 | + $aliases[$connection['type']] : $connection['type']; |
|
| 78 | 77 | $tmp = '\\vakata\\database\\driver\\'.strtolower($connection['type']).'\\Driver'; |
| 79 | 78 | return new $tmp($connection); |
| 80 | 79 | } |
@@ -94,7 +93,7 @@ discard block |
||
| 94 | 93 | $new = ''; |
| 95 | 94 | $par = array_values($par); |
| 96 | 95 | if (substr_count($sql, '?') === 2 && !is_array($par[0])) { |
| 97 | - $par = [ $par ]; |
|
| 96 | + $par = [$par]; |
|
| 98 | 97 | } |
| 99 | 98 | $parts = explode('??', $sql); |
| 100 | 99 | $index = 0; |
@@ -104,7 +103,7 @@ discard block |
||
| 104 | 103 | $index += count($tmp) - 1; |
| 105 | 104 | if (isset($par[$index])) { |
| 106 | 105 | if (!is_array($par[$index])) { |
| 107 | - $par[$index] = [ $par[$index] ]; |
|
| 106 | + $par[$index] = [$par[$index]]; |
|
| 108 | 107 | } |
| 109 | 108 | $params = $par[$index]; |
| 110 | 109 | array_splice($par, $index, 1, $params); |
@@ -112,7 +111,7 @@ discard block |
||
| 112 | 111 | $new .= implode(',', array_fill(0, count($params), '?')); |
| 113 | 112 | } |
| 114 | 113 | } |
| 115 | - return [ $new, $par ]; |
|
| 114 | + return [$new, $par]; |
|
| 116 | 115 | } |
| 117 | 116 | /** |
| 118 | 117 | * Run a query (prepare & execute). |
@@ -144,7 +143,7 @@ discard block |
||
| 144 | 143 | { |
| 145 | 144 | $coll = Collection::from($this->query($sql, $par)); |
| 146 | 145 | if (($keys = $this->driver->option('mode')) && in_array($keys, ['strtoupper', 'strtolower'])) { |
| 147 | - $coll->map(function ($v) use ($keys) { |
|
| 146 | + $coll->map(function($v) use ($keys) { |
|
| 148 | 147 | $new = []; |
| 149 | 148 | foreach ($v as $k => $vv) { |
| 150 | 149 | $new[call_user_func($keys, $k)] = $vv; |
@@ -153,16 +152,16 @@ discard block |
||
| 153 | 152 | }); |
| 154 | 153 | } |
| 155 | 154 | if ($key) { |
| 156 | - $coll->mapKey(function ($v) use ($key) { return $v[$key]; }); |
|
| 155 | + $coll->mapKey(function($v) use ($key) { return $v[$key]; }); |
|
| 157 | 156 | } |
| 158 | 157 | if ($skip) { |
| 159 | - $coll->map(function ($v) use ($key) { unset($v[$key]); return $v; }); |
|
| 158 | + $coll->map(function($v) use ($key) { unset($v[$key]); return $v; }); |
|
| 160 | 159 | } |
| 161 | 160 | if ($opti) { |
| 162 | - $coll->map(function ($v) { return count($v) === 1 ? current($v) : $v; }); |
|
| 161 | + $coll->map(function($v) { return count($v) === 1 ? current($v) : $v; }); |
|
| 163 | 162 | } |
| 164 | 163 | if ($keys) { |
| 165 | - $coll->map(function ($v) use ($key) { unset($v[$key]); return $v; }); |
|
| 164 | + $coll->map(function($v) use ($key) { unset($v[$key]); return $v; }); |
|
| 166 | 165 | } |
| 167 | 166 | return $coll; |
| 168 | 167 | } |
@@ -237,8 +236,7 @@ discard block |
||
| 237 | 236 | public function definition(string $table, bool $detectRelations = true) : Table |
| 238 | 237 | { |
| 239 | 238 | return isset($this->tables[$table]) ? |
| 240 | - $this->tables[$table] : |
|
| 241 | - $this->driver->table($table, $detectRelations); |
|
| 239 | + $this->tables[$table] : $this->driver->table($table, $detectRelations); |
|
| 242 | 240 | } |
| 243 | 241 | /** |
| 244 | 242 | * Parse all tables from the database. |
@@ -255,12 +253,12 @@ discard block |
||
| 255 | 253 | */ |
| 256 | 254 | public function getSchema($asPlainArray = true) |
| 257 | 255 | { |
| 258 | - return !$asPlainArray ? $this->tables : array_map(function ($table) { |
|
| 256 | + return !$asPlainArray ? $this->tables : array_map(function($table) { |
|
| 259 | 257 | return [ |
| 260 | 258 | 'name' => $table->getName(), |
| 261 | 259 | 'pkey' => $table->getPrimaryKey(), |
| 262 | 260 | 'comment' => $table->getComment(), |
| 263 | - 'columns' => array_map(function ($column) { |
|
| 261 | + 'columns' => array_map(function($column) { |
|
| 264 | 262 | return [ |
| 265 | 263 | 'name' => $column->getName(), |
| 266 | 264 | 'type' => $column->getType(), |
@@ -270,13 +268,13 @@ discard block |
||
| 270 | 268 | 'nullable' => $column->isNullable() |
| 271 | 269 | ]; |
| 272 | 270 | }, $table->getFullColumns()), |
| 273 | - 'relations' => array_map(function ($rel) { |
|
| 271 | + 'relations' => array_map(function($rel) { |
|
| 274 | 272 | $relation = clone $rel; |
| 275 | 273 | $relation->table = $relation->table->getName(); |
| 276 | 274 | if ($relation->pivot) { |
| 277 | 275 | $relation->pivot = $relation->pivot->getName(); |
| 278 | 276 | } |
| 279 | - return (array)$relation; |
|
| 277 | + return (array) $relation; |
|
| 280 | 278 | }, $table->getRelations()) |
| 281 | 279 | ]; |
| 282 | 280 | }, $this->tables); |
@@ -15,6 +15,9 @@ |
||
| 15 | 15 | protected $iid = null; |
| 16 | 16 | protected $aff = 0; |
| 17 | 17 | |
| 18 | + /** |
|
| 19 | + * @param integer $aff |
|
| 20 | + */ |
|
| 18 | 21 | public function __construct($statement, $iid, $aff) |
| 19 | 22 | { |
| 20 | 23 | $this->statement = $statement; |
@@ -62,7 +62,7 @@ |
||
| 62 | 62 | } |
| 63 | 63 | public function next() |
| 64 | 64 | { |
| 65 | - $this->fetched ++; |
|
| 65 | + $this->fetched++; |
|
| 66 | 66 | $this->last = \pg_fetch_array($this->statement, null, \PGSQL_ASSOC); |
| 67 | 67 | } |
| 68 | 68 | public function valid() |
@@ -15,6 +15,10 @@ |
||
| 15 | 15 | protected $iid = null; |
| 16 | 16 | protected $aff = 0; |
| 17 | 17 | |
| 18 | + /** |
|
| 19 | + * @param integer $iid |
|
| 20 | + * @param integer $aff |
|
| 21 | + */ |
|
| 18 | 22 | public function __construct(\SQLite3Result $statement, $iid, $aff) |
| 19 | 23 | { |
| 20 | 24 | $this->statement = $statement; |
@@ -62,7 +62,7 @@ |
||
| 62 | 62 | } |
| 63 | 63 | public function next() |
| 64 | 64 | { |
| 65 | - $this->fetched ++; |
|
| 65 | + $this->fetched++; |
|
| 66 | 66 | $this->last = $this->statement->fetchArray(\SQLITE3_ASSOC); |
| 67 | 67 | } |
| 68 | 68 | public function valid() |
@@ -35,7 +35,6 @@ discard block |
||
| 35 | 35 | /** |
| 36 | 36 | * Run a query (prepare & execute). |
| 37 | 37 | * @param string $sql SQL query |
| 38 | - * @param array $data parameters (optional) |
|
| 39 | 38 | * @return ResultInterface the result of the execution |
| 40 | 39 | */ |
| 41 | 40 | public function query(string $sql, $par = null) : ResultInterface |
@@ -50,6 +49,13 @@ discard block |
||
| 50 | 49 | { |
| 51 | 50 | return $this->connection['name']; |
| 52 | 51 | } |
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * @param string $key |
|
| 55 | + * @param string $default |
|
| 56 | + * |
|
| 57 | + * @return string |
|
| 58 | + */ |
|
| 53 | 59 | public function option($key, $default = null) |
| 54 | 60 | { |
| 55 | 61 | return isset($this->connection['opts'][$key]) ? $this->connection['opts'][$key] : $default; |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | $new = ''; |
| 13 | 13 | $par = array_values($par); |
| 14 | 14 | if (substr_count($sql, '?') === 2 && !is_array($par[0])) { |
| 15 | - $par = [ $par ]; |
|
| 15 | + $par = [$par]; |
|
| 16 | 16 | } |
| 17 | 17 | $parts = explode('??', $sql); |
| 18 | 18 | $index = 0; |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | $index += count($tmp) - 1; |
| 23 | 23 | if (isset($par[$index])) { |
| 24 | 24 | if (!is_array($par[$index])) { |
| 25 | - $par[$index] = [ $par[$index] ]; |
|
| 25 | + $par[$index] = [$par[$index]]; |
|
| 26 | 26 | } |
| 27 | 27 | $params = $par[$index]; |
| 28 | 28 | array_splice($par, $index, 1, $params); |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | $new .= implode(',', array_fill(0, count($params), '?')); |
| 31 | 31 | } |
| 32 | 32 | } |
| 33 | - return [ $new, $par ]; |
|
| 33 | + return [$new, $par]; |
|
| 34 | 34 | } |
| 35 | 35 | /** |
| 36 | 36 | * Run a query (prepare & execute). |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | /** |
| 57 | 57 | * Create an instance |
| 58 | 58 | * @param DBInterface $db the database connection |
| 59 | - * @param Table|string $definition the name or definition of the main table in the query |
|
| 59 | + * @param Table $table |
|
| 60 | 60 | */ |
| 61 | 61 | public function __construct(DBInterface $db, $table) |
| 62 | 62 | { |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | } |
| 192 | 192 | /** |
| 193 | 193 | * Group by a column (or columns) |
| 194 | - * @param string|array $column the column name (or names) to group by |
|
| 194 | + * @param string $column the column name (or names) to group by |
|
| 195 | 195 | * @return $this |
| 196 | 196 | */ |
| 197 | 197 | public function group($column) : TableQuery |
@@ -3,7 +3,6 @@ |
||
| 3 | 3 | |
| 4 | 4 | use vakata\database\DBInterface; |
| 5 | 5 | use vakata\database\DBException; |
| 6 | -use vakata\database\ResultInterface; |
|
| 7 | 6 | |
| 8 | 7 | /** |
| 9 | 8 | * A database query class |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | /** |
| 44 | 44 | * @var int[] |
| 45 | 45 | */ |
| 46 | - protected $li_of = [0,0]; |
|
| 46 | + protected $li_of = [0, 0]; |
|
| 47 | 47 | /** |
| 48 | 48 | * @var array |
| 49 | 49 | */ |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | public function __construct(DBInterface $db, $table) |
| 66 | 66 | { |
| 67 | 67 | $this->db = $db; |
| 68 | - $this->definition = $table instanceof Table ? $table : $this->db->definition((string)$table); |
|
| 68 | + $this->definition = $table instanceof Table ? $table : $this->db->definition((string) $table); |
|
| 69 | 69 | $this->columns($this->definition->getColumns()); |
| 70 | 70 | } |
| 71 | 71 | public function __clone() |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | { |
| 86 | 86 | $column = explode('.', $column); |
| 87 | 87 | if (count($column) === 1) { |
| 88 | - $column = [ $this->definition->getName(), $column[0] ]; |
|
| 88 | + $column = [$this->definition->getName(), $column[0]]; |
|
| 89 | 89 | $col = $this->definition->getColumn($column[1]); |
| 90 | 90 | } elseif (count($column) === 2) { |
| 91 | 91 | if ($column[0] === $this->definition->getName()) { |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | throw new DBException('Invalid column name in related table'); |
| 106 | 106 | } |
| 107 | 107 | } else { |
| 108 | - throw new DBException('Invalid foreign table name: ' . implode(',', $column)); |
|
| 108 | + throw new DBException('Invalid foreign table name: '.implode(',', $column)); |
|
| 109 | 109 | } |
| 110 | 110 | } |
| 111 | 111 | } else { |
@@ -114,15 +114,15 @@ discard block |
||
| 114 | 114 | $table = $this->definition; |
| 115 | 115 | $table = array_reduce( |
| 116 | 116 | $column, |
| 117 | - function ($carry, $item) use (&$table) { |
|
| 117 | + function($carry, $item) use (&$table) { |
|
| 118 | 118 | $table = $table->getRelation($item)->table; |
| 119 | 119 | return $table; |
| 120 | 120 | } |
| 121 | 121 | ); |
| 122 | 122 | $col = $table->getColumn($name); |
| 123 | - $column = [ implode(static::SEP, $column), $name ]; |
|
| 123 | + $column = [implode(static::SEP, $column), $name]; |
|
| 124 | 124 | } |
| 125 | - return [ 'name' => implode('.', $column), 'data' => $col ]; |
|
| 125 | + return ['name' => implode('.', $column), 'data' => $col]; |
|
| 126 | 126 | } |
| 127 | 127 | protected function normalizeValue(TableColumn $col, $value) |
| 128 | 128 | { |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | } |
| 162 | 162 | return $value; |
| 163 | 163 | case 'int': |
| 164 | - return (int)$value; |
|
| 164 | + return (int) $value; |
|
| 165 | 165 | default: |
| 166 | 166 | return $value; |
| 167 | 167 | } |
@@ -178,18 +178,16 @@ discard block |
||
| 178 | 178 | list($name, $column) = array_values($this->getColumn($column)); |
| 179 | 179 | if (is_null($value)) { |
| 180 | 180 | return $negate ? |
| 181 | - $this->where($name . ' IS NOT NULL') : |
|
| 182 | - $this->where($name . ' IS NULL'); |
|
| 181 | + $this->where($name.' IS NOT NULL') : $this->where($name.' IS NULL'); |
|
| 183 | 182 | } |
| 184 | 183 | if (!is_array($value)) { |
| 185 | 184 | return $negate ? |
| 186 | 185 | $this->where( |
| 187 | - $name . ' <> ?', |
|
| 188 | - [ $this->normalizeValue($column, $value) ] |
|
| 189 | - ) : |
|
| 190 | - $this->where( |
|
| 191 | - $name . ' = ?', |
|
| 192 | - [ $this->normalizeValue($column, $value) ] |
|
| 186 | + $name.' <> ?', |
|
| 187 | + [$this->normalizeValue($column, $value)] |
|
| 188 | + ) : $this->where( |
|
| 189 | + $name.' = ?', |
|
| 190 | + [$this->normalizeValue($column, $value)] |
|
| 193 | 191 | ); |
| 194 | 192 | } |
| 195 | 193 | if (isset($value['beg']) && isset($value['end'])) { |
@@ -200,8 +198,7 @@ discard block |
||
| 200 | 198 | $this->normalizeValue($column, $value['beg']), |
| 201 | 199 | $this->normalizeValue($column, $value['end']) |
| 202 | 200 | ] |
| 203 | - ) : |
|
| 204 | - $this->where( |
|
| 201 | + ) : $this->where( |
|
| 205 | 202 | $name.' BETWEEN ? AND ?', |
| 206 | 203 | [ |
| 207 | 204 | $this->normalizeValue($column, $value['beg']), |
@@ -211,12 +208,12 @@ discard block |
||
| 211 | 208 | } |
| 212 | 209 | return $negate ? |
| 213 | 210 | $this->where( |
| 214 | - $name . ' NOT IN (??)', |
|
| 215 | - [ array_map(function ($v) use ($column) { return $this->normalizeValue($column, $v); }, $value) ] |
|
| 211 | + $name.' NOT IN (??)', |
|
| 212 | + [array_map(function($v) use ($column) { return $this->normalizeValue($column, $v); }, $value)] |
|
| 216 | 213 | ) : |
| 217 | 214 | $this->where( |
| 218 | - $name . ' IN (??)', |
|
| 219 | - [ array_map(function ($v) use ($column) { return $this->normalizeValue($column, $v); }, $value) ] |
|
| 215 | + $name.' IN (??)', |
|
| 216 | + [array_map(function($v) use ($column) { return $this->normalizeValue($column, $v); }, $value)] |
|
| 220 | 217 | ); |
| 221 | 218 | } |
| 222 | 219 | /** |
@@ -227,7 +224,7 @@ discard block |
||
| 227 | 224 | */ |
| 228 | 225 | public function sort(string $column, bool $desc = false) : TableQuery |
| 229 | 226 | { |
| 230 | - return $this->order($this->getColumn($column)['name'] . ' ' . ($desc ? 'DESC' : 'ASC')); |
|
| 227 | + return $this->order($this->getColumn($column)['name'].' '.($desc ? 'DESC' : 'ASC')); |
|
| 231 | 228 | } |
| 232 | 229 | /** |
| 233 | 230 | * Group by a column (or columns) |
@@ -237,7 +234,7 @@ discard block |
||
| 237 | 234 | public function group($column) : TableQuery |
| 238 | 235 | { |
| 239 | 236 | if (!is_array($column)) { |
| 240 | - $column = [ $column ]; |
|
| 237 | + $column = [$column]; |
|
| 241 | 238 | } |
| 242 | 239 | foreach ($column as $k => $v) { |
| 243 | 240 | $column[$k] = $this->getColumn($v)['name']; |
@@ -278,7 +275,7 @@ discard block |
||
| 278 | 275 | $this->withr = []; |
| 279 | 276 | $this->order = []; |
| 280 | 277 | $this->having = []; |
| 281 | - $this->li_of = [0,0]; |
|
| 278 | + $this->li_of = [0, 0]; |
|
| 282 | 279 | $this->qiterator = null; |
| 283 | 280 | return $this; |
| 284 | 281 | } |
@@ -291,7 +288,7 @@ discard block |
||
| 291 | 288 | public function groupBy(string $sql, array $params = []) : TableQuery |
| 292 | 289 | { |
| 293 | 290 | $this->qiterator = null; |
| 294 | - $this->group = [ $sql, $params ]; |
|
| 291 | + $this->group = [$sql, $params]; |
|
| 295 | 292 | return $this; |
| 296 | 293 | } |
| 297 | 294 | /** |
@@ -304,7 +301,7 @@ discard block |
||
| 304 | 301 | */ |
| 305 | 302 | public function join($table, array $fields, string $name = null, bool $multiple = true) |
| 306 | 303 | { |
| 307 | - $table = $table instanceof Table ? $table : $this->db->definition((string)$table); |
|
| 304 | + $table = $table instanceof Table ? $table : $this->db->definition((string) $table); |
|
| 308 | 305 | $name = $name ?? $table->getName(); |
| 309 | 306 | if (isset($this->joins[$name]) || $this->definition->hasRelation($name)) { |
| 310 | 307 | throw new DBException('Alias / table name already in use'); |
@@ -313,7 +310,7 @@ discard block |
||
| 313 | 310 | foreach ($fields as $k => $v) { |
| 314 | 311 | $k = explode('.', $k, 2); |
| 315 | 312 | $k = count($k) == 2 ? $k[1] : $k[0]; |
| 316 | - $this->joins[$name]->keymap[$this->getColumn($name . '.' . $k)['name']] = $this->getColumn($v)['name']; |
|
| 313 | + $this->joins[$name]->keymap[$this->getColumn($name.'.'.$k)['name']] = $this->getColumn($v)['name']; |
|
| 317 | 314 | } |
| 318 | 315 | return $this; |
| 319 | 316 | } |
@@ -326,7 +323,7 @@ discard block |
||
| 326 | 323 | public function where(string $sql, array $params = []) : TableQuery |
| 327 | 324 | { |
| 328 | 325 | $this->qiterator = null; |
| 329 | - $this->where[] = [ $sql, $params ]; |
|
| 326 | + $this->where[] = [$sql, $params]; |
|
| 330 | 327 | return $this; |
| 331 | 328 | } |
| 332 | 329 | /** |
@@ -338,7 +335,7 @@ discard block |
||
| 338 | 335 | public function having(string $sql, array $params = []) : TableQuery |
| 339 | 336 | { |
| 340 | 337 | $this->qiterator = null; |
| 341 | - $this->having[] = [ $sql, $params ]; |
|
| 338 | + $this->having[] = [$sql, $params]; |
|
| 342 | 339 | return $this; |
| 343 | 340 | } |
| 344 | 341 | /** |
@@ -350,7 +347,7 @@ discard block |
||
| 350 | 347 | public function order(string $sql, array $params = []) : TableQuery |
| 351 | 348 | { |
| 352 | 349 | $this->qiterator = null; |
| 353 | - $this->order = [ $sql, $params ]; |
|
| 350 | + $this->order = [$sql, $params]; |
|
| 354 | 351 | return $this; |
| 355 | 352 | } |
| 356 | 353 | /** |
@@ -362,7 +359,7 @@ discard block |
||
| 362 | 359 | public function limit(int $limit, int $offset = 0) : TableQuery |
| 363 | 360 | { |
| 364 | 361 | $this->qiterator = null; |
| 365 | - $this->li_of = [ $limit, $offset ]; |
|
| 362 | + $this->li_of = [$limit, $offset]; |
|
| 366 | 363 | return $this; |
| 367 | 364 | } |
| 368 | 365 | /** |
@@ -379,22 +376,22 @@ discard block |
||
| 379 | 376 | $relations = $this->withr; |
| 380 | 377 | foreach ($this->definition->getRelations() as $k => $v) { |
| 381 | 378 | foreach ($this->where as $vv) { |
| 382 | - if (strpos($vv[0], $k . '.') !== false) { |
|
| 383 | - $relations[$k] = [ $v, $table ]; |
|
| 379 | + if (strpos($vv[0], $k.'.') !== false) { |
|
| 380 | + $relations[$k] = [$v, $table]; |
|
| 384 | 381 | } |
| 385 | 382 | } |
| 386 | - if (isset($this->order[0]) && strpos($this->order[0], $k . '.') !== false) { |
|
| 387 | - $relations[$k] = [ $v, $table ]; |
|
| 383 | + if (isset($this->order[0]) && strpos($this->order[0], $k.'.') !== false) { |
|
| 384 | + $relations[$k] = [$v, $table]; |
|
| 388 | 385 | } |
| 389 | 386 | } |
| 390 | 387 | |
| 391 | 388 | foreach ($this->joins as $k => $v) { |
| 392 | - $sql .= ($v->many ? 'LEFT ' : '' ) . 'JOIN '.$v->table->getName().' '.$k.' ON '; |
|
| 389 | + $sql .= ($v->many ? 'LEFT ' : '').'JOIN '.$v->table->getName().' '.$k.' ON '; |
|
| 393 | 390 | $tmp = []; |
| 394 | 391 | foreach ($v->keymap as $kk => $vv) { |
| 395 | 392 | $tmp[] = $kk.' = '.$vv; |
| 396 | 393 | } |
| 397 | - $sql .= implode(' AND ', $tmp) . ' '; |
|
| 394 | + $sql .= implode(' AND ', $tmp).' '; |
|
| 398 | 395 | } |
| 399 | 396 | foreach ($relations as $k => $v) { |
| 400 | 397 | $table = $v[1]; |
@@ -405,13 +402,13 @@ discard block |
||
| 405 | 402 | foreach ($v->keymap as $kk => $vv) { |
| 406 | 403 | $tmp[] = $table.'.'.$kk.' = '.$k.'_pivot.'.$vv.' '; |
| 407 | 404 | } |
| 408 | - $sql .= implode(' AND ', $tmp) . ' '; |
|
| 405 | + $sql .= implode(' AND ', $tmp).' '; |
|
| 409 | 406 | $sql .= 'LEFT JOIN '.$v->table->getName().' '.$k.' ON '; |
| 410 | 407 | $tmp = []; |
| 411 | 408 | foreach ($v->pivot_keymap as $kk => $vv) { |
| 412 | 409 | $tmp[] = $k.'.'.$vv.' = '.$k.'_pivot.'.$kk.' '; |
| 413 | 410 | } |
| 414 | - $sql .= implode(' AND ', $tmp) . ' '; |
|
| 411 | + $sql .= implode(' AND ', $tmp).' '; |
|
| 415 | 412 | } else { |
| 416 | 413 | $sql .= 'LEFT JOIN '.$v->table->getName().' '.$k.' ON '; |
| 417 | 414 | $tmp = []; |
@@ -419,30 +416,30 @@ discard block |
||
| 419 | 416 | $tmp[] = $table.'.'.$kk.' = '.$k.'.'.$vv.' '; |
| 420 | 417 | } |
| 421 | 418 | if ($v->sql) { |
| 422 | - $tmp[] = $v->sql . ' '; |
|
| 419 | + $tmp[] = $v->sql.' '; |
|
| 423 | 420 | $par = array_merge($par, $v->par ?? []); |
| 424 | 421 | } |
| 425 | - $sql .= implode(' AND ', $tmp) . ' '; |
|
| 422 | + $sql .= implode(' AND ', $tmp).' '; |
|
| 426 | 423 | } |
| 427 | 424 | } |
| 428 | 425 | if (count($this->where)) { |
| 429 | 426 | $sql .= 'WHERE '; |
| 430 | 427 | $tmp = []; |
| 431 | 428 | foreach ($this->where as $v) { |
| 432 | - $tmp[] = '(' . $v[0] . ')'; |
|
| 429 | + $tmp[] = '('.$v[0].')'; |
|
| 433 | 430 | $par = array_merge($par, $v[1]); |
| 434 | 431 | } |
| 435 | 432 | $sql .= implode(' AND ', $tmp).' '; |
| 436 | 433 | } |
| 437 | 434 | if (count($this->group)) { |
| 438 | - $sql .= 'GROUP BY ' . $this->group[0] . ' '; |
|
| 435 | + $sql .= 'GROUP BY '.$this->group[0].' '; |
|
| 439 | 436 | $par = array_merge($par, $this->group[1]); |
| 440 | 437 | } |
| 441 | 438 | if (count($this->having)) { |
| 442 | 439 | $sql .= 'HAVING '; |
| 443 | 440 | $tmp = []; |
| 444 | 441 | foreach ($this->having as $v) { |
| 445 | - $tmp[] = '(' . $v[0] . ')'; |
|
| 442 | + $tmp[] = '('.$v[0].')'; |
|
| 446 | 443 | $par = array_merge($par, $v[1]); |
| 447 | 444 | } |
| 448 | 445 | $sql .= implode(' AND ', $tmp).' '; |
@@ -478,7 +475,7 @@ discard block |
||
| 478 | 475 | $this->with(implode('.', $temp)); |
| 479 | 476 | $table = array_reduce( |
| 480 | 477 | $temp, |
| 481 | - function ($carry, $item) use (&$table) { |
|
| 478 | + function($carry, $item) use (&$table) { |
|
| 482 | 479 | return $table->getRelation($item)->table; |
| 483 | 480 | } |
| 484 | 481 | ); |
@@ -487,7 +484,7 @@ discard block |
||
| 487 | 484 | } |
| 488 | 485 | unset($fields[$k]); |
| 489 | 486 | foreach ($cols as $col) { |
| 490 | - $fields[] = $table . '.' . $col; |
|
| 487 | + $fields[] = $table.'.'.$col; |
|
| 491 | 488 | } |
| 492 | 489 | } |
| 493 | 490 | } |
@@ -526,37 +523,37 @@ discard block |
||
| 526 | 523 | $relations = $this->withr; |
| 527 | 524 | foreach ($this->definition->getRelations() as $k => $relation) { |
| 528 | 525 | foreach ($this->fields as $field) { |
| 529 | - if (strpos($field, $k . '.') === 0) { |
|
| 530 | - $relations[$k] = [ $relation, $table ]; |
|
| 526 | + if (strpos($field, $k.'.') === 0) { |
|
| 527 | + $relations[$k] = [$relation, $table]; |
|
| 531 | 528 | } |
| 532 | 529 | } |
| 533 | 530 | foreach ($this->where as $v) { |
| 534 | - if (strpos($v[0], $k . '.') !== false) { |
|
| 535 | - $relations[$k] = [ $relation, $table ]; |
|
| 531 | + if (strpos($v[0], $k.'.') !== false) { |
|
| 532 | + $relations[$k] = [$relation, $table]; |
|
| 536 | 533 | } |
| 537 | 534 | } |
| 538 | - if (isset($this->order[0]) && strpos($this->order[0], $k . '.') !== false) { |
|
| 539 | - $relations[$k] = [ $relation, $table ]; |
|
| 535 | + if (isset($this->order[0]) && strpos($this->order[0], $k.'.') !== false) { |
|
| 536 | + $relations[$k] = [$relation, $table]; |
|
| 540 | 537 | } |
| 541 | 538 | } |
| 542 | 539 | $select = []; |
| 543 | 540 | foreach ($this->fields as $k => $field) { |
| 544 | - $select[] = $field . (!is_numeric($k) ? ' ' . $k : ''); |
|
| 541 | + $select[] = $field.(!is_numeric($k) ? ' '.$k : ''); |
|
| 545 | 542 | } |
| 546 | 543 | foreach ($this->withr as $name => $relation) { |
| 547 | 544 | foreach ($relation[0]->table->getColumns() as $column) { |
| 548 | - $select[] = $name . '.' . $column . ' ' . $name . static::SEP . $column; |
|
| 545 | + $select[] = $name.'.'.$column.' '.$name.static::SEP.$column; |
|
| 549 | 546 | } |
| 550 | 547 | } |
| 551 | 548 | $sql = 'SELECT '.implode(', ', $select).' FROM '.$table.' '; |
| 552 | 549 | $par = []; |
| 553 | 550 | foreach ($this->joins as $k => $v) { |
| 554 | - $sql .= ($v->many ? 'LEFT ' : '' ) . 'JOIN '.$v->table->getName().' '.$k.' ON '; |
|
| 551 | + $sql .= ($v->many ? 'LEFT ' : '').'JOIN '.$v->table->getName().' '.$k.' ON '; |
|
| 555 | 552 | $tmp = []; |
| 556 | 553 | foreach ($v->keymap as $kk => $vv) { |
| 557 | 554 | $tmp[] = $kk.' = '.$vv; |
| 558 | 555 | } |
| 559 | - $sql .= implode(' AND ', $tmp) . ' '; |
|
| 556 | + $sql .= implode(' AND ', $tmp).' '; |
|
| 560 | 557 | } |
| 561 | 558 | foreach ($relations as $relation => $v) { |
| 562 | 559 | $table = $v[1]; |
@@ -567,13 +564,13 @@ discard block |
||
| 567 | 564 | foreach ($v->keymap as $kk => $vv) { |
| 568 | 565 | $tmp[] = $table.'.'.$kk.' = '.$relation.'_pivot.'.$vv.' '; |
| 569 | 566 | } |
| 570 | - $sql .= implode(' AND ', $tmp) . ' '; |
|
| 567 | + $sql .= implode(' AND ', $tmp).' '; |
|
| 571 | 568 | $sql .= 'LEFT JOIN '.$v->table->getName().' '.$relation.' ON '; |
| 572 | 569 | $tmp = []; |
| 573 | 570 | foreach ($v->pivot_keymap as $kk => $vv) { |
| 574 | 571 | $tmp[] = $relation.'.'.$vv.' = '.$relation.'_pivot.'.$kk.' '; |
| 575 | 572 | } |
| 576 | - $sql .= implode(' AND ', $tmp) . ' '; |
|
| 573 | + $sql .= implode(' AND ', $tmp).' '; |
|
| 577 | 574 | } else { |
| 578 | 575 | $sql .= 'LEFT JOIN '.$v->table->getName().' '.$relation.' ON '; |
| 579 | 576 | $tmp = []; |
@@ -581,30 +578,30 @@ discard block |
||
| 581 | 578 | $tmp[] = $table.'.'.$kk.' = '.$relation.'.'.$vv.' '; |
| 582 | 579 | } |
| 583 | 580 | if ($v->sql) { |
| 584 | - $tmp[] = $v->sql . ' '; |
|
| 581 | + $tmp[] = $v->sql.' '; |
|
| 585 | 582 | $par = array_merge($par, $v->par ?? []); |
| 586 | 583 | } |
| 587 | - $sql .= implode(' AND ', $tmp) . ' '; |
|
| 584 | + $sql .= implode(' AND ', $tmp).' '; |
|
| 588 | 585 | } |
| 589 | 586 | } |
| 590 | 587 | if (count($this->where)) { |
| 591 | 588 | $sql .= 'WHERE '; |
| 592 | 589 | $tmp = []; |
| 593 | 590 | foreach ($this->where as $v) { |
| 594 | - $tmp[] = '(' . $v[0] . ')'; |
|
| 591 | + $tmp[] = '('.$v[0].')'; |
|
| 595 | 592 | $par = array_merge($par, $v[1]); |
| 596 | 593 | } |
| 597 | 594 | $sql .= implode(' AND ', $tmp).' '; |
| 598 | 595 | } |
| 599 | 596 | if (count($this->group)) { |
| 600 | - $sql .= 'GROUP BY ' . $this->group[0] . ' '; |
|
| 597 | + $sql .= 'GROUP BY '.$this->group[0].' '; |
|
| 601 | 598 | $par = array_merge($par, $this->group[1]); |
| 602 | 599 | } |
| 603 | 600 | if (count($this->having)) { |
| 604 | 601 | $sql .= 'HAVING '; |
| 605 | 602 | $tmp = []; |
| 606 | 603 | foreach ($this->having as $v) { |
| 607 | - $tmp[] = '(' . $v[0] . ')'; |
|
| 604 | + $tmp[] = '('.$v[0].')'; |
|
| 608 | 605 | $par = array_merge($par, $v[1]); |
| 609 | 606 | } |
| 610 | 607 | $sql .= implode(' AND ', $tmp).' '; |
@@ -613,36 +610,36 @@ discard block |
||
| 613 | 610 | // $sql .= 'GROUP BY '.$table.'.'.implode(', '.$table.'.', $primary).' '; |
| 614 | 611 | //} |
| 615 | 612 | if (count($this->order)) { |
| 616 | - $sql .= 'ORDER BY ' . $this->order[0] . ' '; |
|
| 613 | + $sql .= 'ORDER BY '.$this->order[0].' '; |
|
| 617 | 614 | $par = array_merge($par, $this->order[1]); |
| 618 | 615 | } |
| 619 | 616 | $porder = []; |
| 620 | 617 | foreach ($primary as $field) { |
| 621 | 618 | $porder[] = $this->getColumn($field)['name']; |
| 622 | 619 | } |
| 623 | - $sql .= (count($this->order) ? ', ' : 'ORDER BY ') . implode(', ', $porder) . ' '; |
|
| 620 | + $sql .= (count($this->order) ? ', ' : 'ORDER BY ').implode(', ', $porder).' '; |
|
| 624 | 621 | |
| 625 | 622 | if ($this->li_of[0]) { |
| 626 | 623 | if ($this->db->driver() === 'oracle') { |
| 627 | - if ((int)($this->db->settings()->options['version'] ?? 0) >= 12) { |
|
| 628 | - $sql .= 'OFFSET ' . $this->li_of[1] . ' ROWS FETCH NEXT ' . $this->li_of[0] . ' ROWS ONLY'; |
|
| 624 | + if ((int) ($this->db->settings()->options['version'] ?? 0) >= 12) { |
|
| 625 | + $sql .= 'OFFSET '.$this->li_of[1].' ROWS FETCH NEXT '.$this->li_of[0].' ROWS ONLY'; |
|
| 629 | 626 | } else { |
| 630 | - $f = array_map(function ($v) { |
|
| 627 | + $f = array_map(function($v) { |
|
| 631 | 628 | $v = explode(' ', trim($v), 2); |
| 632 | 629 | if (count($v) === 2) { return $v[1]; } |
| 633 | 630 | $v = explode('.', $v[0], 2); |
| 634 | 631 | return count($v) === 2 ? $v[1] : $v[0]; |
| 635 | 632 | }, $select); |
| 636 | - $sql = "SELECT " . implode(', ', $f) . " |
|
| 633 | + $sql = "SELECT ".implode(', ', $f)." |
|
| 637 | 634 | FROM ( |
| 638 | 635 | SELECT tbl__.*, rownum rnum__ FROM ( |
| 639 | - " . $sql . " |
|
| 636 | + " . $sql." |
|
| 640 | 637 | ) tbl__ |
| 641 | - WHERE rownum <= " . ($this->li_of[0] + $this->li_of[1]) . " |
|
| 638 | + WHERE rownum <= " . ($this->li_of[0] + $this->li_of[1])." |
|
| 642 | 639 | ) WHERE rnum__ > " . $this->li_of[1]; |
| 643 | 640 | } |
| 644 | 641 | } else { |
| 645 | - $sql .= 'LIMIT ' . $this->li_of[0] . ' OFFSET ' . $this->li_of[1]; |
|
| 642 | + $sql .= 'LIMIT '.$this->li_of[0].' OFFSET '.$this->li_of[1]; |
|
| 646 | 643 | } |
| 647 | 644 | } |
| 648 | 645 | return $this->qiterator = new TableQueryIterator( |
@@ -692,7 +689,7 @@ discard block |
||
| 692 | 689 | $ret[$k] = str_repeat(' ', 255); |
| 693 | 690 | $par[] = &$ret[$k]; |
| 694 | 691 | } |
| 695 | - $sql .= ' RETURNING ' . implode(',', $primary) . ' INTO ' . implode(',', array_fill(0, count($primary), '?')); |
|
| 692 | + $sql .= ' RETURNING '.implode(',', $primary).' INTO '.implode(',', array_fill(0, count($primary), '?')); |
|
| 696 | 693 | $this->db->query($sql, $par); |
| 697 | 694 | return $ret; |
| 698 | 695 | } else { |
@@ -724,7 +721,7 @@ discard block |
||
| 724 | 721 | } |
| 725 | 722 | $sql = 'UPDATE '.$table.' SET '; |
| 726 | 723 | $par = []; |
| 727 | - $sql .= implode(', ', array_map(function ($v) { return $v . ' = ?'; }, array_keys($update))) . ' '; |
|
| 724 | + $sql .= implode(', ', array_map(function($v) { return $v.' = ?'; }, array_keys($update))).' '; |
|
| 728 | 725 | $par = array_merge($par, array_values($update)); |
| 729 | 726 | if (count($this->where)) { |
| 730 | 727 | $sql .= 'WHERE '; |
@@ -733,7 +730,7 @@ discard block |
||
| 733 | 730 | $tmp[] = $v[0]; |
| 734 | 731 | $par = array_merge($par, $v[1]); |
| 735 | 732 | } |
| 736 | - $sql .= implode(' AND ', $tmp) . ' '; |
|
| 733 | + $sql .= implode(' AND ', $tmp).' '; |
|
| 737 | 734 | } |
| 738 | 735 | if (count($this->order)) { |
| 739 | 736 | $sql .= $this->order[0]; |
@@ -757,7 +754,7 @@ discard block |
||
| 757 | 754 | $tmp[] = $v[0]; |
| 758 | 755 | $par = array_merge($par, $v[1]); |
| 759 | 756 | } |
| 760 | - $sql .= implode(' AND ', $tmp) . ' '; |
|
| 757 | + $sql .= implode(' AND ', $tmp).' '; |
|
| 761 | 758 | } |
| 762 | 759 | if (count($this->order)) { |
| 763 | 760 | $sql .= $this->order[0]; |
@@ -777,13 +774,13 @@ discard block |
||
| 777 | 774 | $table = $this->definition; |
| 778 | 775 | array_reduce( |
| 779 | 776 | $parts, |
| 780 | - function ($carry, $item) use (&$table) { |
|
| 777 | + function($carry, $item) use (&$table) { |
|
| 781 | 778 | $relation = $table->getRelation($item); |
| 782 | 779 | if (!$relation) { |
| 783 | 780 | throw new DBException('Invalid relation name'); |
| 784 | 781 | } |
| 785 | - $name = $carry ? $carry . static::SEP . $item : $item; |
|
| 786 | - $this->withr[$name] = [ $relation, $carry ?? $table->getName() ]; |
|
| 782 | + $name = $carry ? $carry.static::SEP.$item : $item; |
|
| 783 | + $this->withr[$name] = [$relation, $carry ?? $table->getName()]; |
|
| 787 | 784 | $table = $relation->table; |
| 788 | 785 | return $name; |
| 789 | 786 | } |
@@ -23,8 +23,7 @@ |
||
| 23 | 23 | $data = array(); |
| 24 | 24 | } |
| 25 | 25 | $temp = (is_array($data) && count($data)) ? |
| 26 | - \pg_query_params($this->driver, $this->statement, $data) : |
|
| 27 | - \pg_query_params($this->driver, $this->statement, array()); |
|
| 26 | + \pg_query_params($this->driver, $this->statement, $data) : \pg_query_params($this->driver, $this->statement, array()); |
|
| 28 | 27 | if (!$temp) { |
| 29 | 28 | throw new DBException('Could not execute query : '.\pg_last_error($this->driver).' <'.$this->statement.'>'); |
| 30 | 29 | } |
@@ -64,7 +64,7 @@ |
||
| 64 | 64 | } |
| 65 | 65 | public function next() |
| 66 | 66 | { |
| 67 | - $this->fetched ++; |
|
| 67 | + $this->fetched++; |
|
| 68 | 68 | $this->last = \oci_fetch_array($this->statement, \OCI_ASSOC + \OCI_RETURN_NULLS + \OCI_RETURN_LOBS); |
| 69 | 69 | } |
| 70 | 70 | public function valid() |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | |
| 76 | 76 | public function begin() : bool |
| 77 | 77 | { |
| 78 | - return $this->transaction = true; |
|
| 78 | + return $this->transaction = true; |
|
| 79 | 79 | } |
| 80 | 80 | public function commit() : bool |
| 81 | 81 | { |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | } |
| 200 | 200 | return $new; |
| 201 | 201 | }) |
| 202 | - as $relation |
|
| 202 | + as $relation |
|
| 203 | 203 | ) { |
| 204 | 204 | $relations[$relation['CONSTRAINT_NAME']]['table'] = $relation['TABLE_NAME']; |
| 205 | 205 | $relations[$relation['CONSTRAINT_NAME']]['keymap'][$primary[(int)$relation['POSITION']-1]] = $relation['COLUMN_NAME']; |
@@ -125,16 +125,16 @@ discard block |
||
| 125 | 125 | $columns = Collection::from($this |
| 126 | 126 | ->query( |
| 127 | 127 | "SELECT * FROM all_tab_cols WHERE table_name = ? AND owner = ?", |
| 128 | - [ strtoupper($table), $this->name() ] |
|
| 128 | + [strtoupper($table), $this->name()] |
|
| 129 | 129 | )) |
| 130 | - ->map(function ($v) { |
|
| 130 | + ->map(function($v) { |
|
| 131 | 131 | $new = []; |
| 132 | 132 | foreach ($v as $kk => $vv) { |
| 133 | 133 | $new[strtoupper($kk)] = $vv; |
| 134 | 134 | } |
| 135 | 135 | return $new; |
| 136 | 136 | }) |
| 137 | - ->mapKey(function ($v) { return $v['COLUMN_NAME']; }) |
|
| 137 | + ->mapKey(function($v) { return $v['COLUMN_NAME']; }) |
|
| 138 | 138 | ->toArray(); |
| 139 | 139 | if (!count($columns)) { |
| 140 | 140 | throw new DBException('Table not found by name'); |
@@ -144,9 +144,9 @@ discard block |
||
| 144 | 144 | ->query( |
| 145 | 145 | "SELECT constraint_name FROM all_constraints |
| 146 | 146 | WHERE table_name = ? AND constraint_type = ? AND owner = ?", |
| 147 | - [ strtoupper($table), 'P', $owner ] |
|
| 147 | + [strtoupper($table), 'P', $owner] |
|
| 148 | 148 | )) |
| 149 | - ->map(function ($v) { |
|
| 149 | + ->map(function($v) { |
|
| 150 | 150 | $new = []; |
| 151 | 151 | foreach ($v as $kk => $vv) { |
| 152 | 152 | $new[strtoupper($kk)] = $vv; |
@@ -161,9 +161,9 @@ discard block |
||
| 161 | 161 | ->query( |
| 162 | 162 | "SELECT column_name FROM all_cons_columns |
| 163 | 163 | WHERE table_name = ? AND constraint_name = ? AND owner = ?", |
| 164 | - [ strtoupper($table), $pkname, $owner ] |
|
| 164 | + [strtoupper($table), $pkname, $owner] |
|
| 165 | 165 | )) |
| 166 | - ->map(function ($v) { |
|
| 166 | + ->map(function($v) { |
|
| 167 | 167 | $new = []; |
| 168 | 168 | foreach ($v as $kk => $vv) { |
| 169 | 169 | $new[strtoupper($kk)] = $vv; |
@@ -190,9 +190,9 @@ discard block |
||
| 190 | 190 | LEFT JOIN all_cons_columns cc ON cc.OWNER = ac.OWNER AND cc.CONSTRAINT_NAME = ac.CONSTRAINT_NAME |
| 191 | 191 | WHERE ac.OWNER = ? AND ac.R_OWNER = ? AND ac.R_CONSTRAINT_NAME = ? AND ac.CONSTRAINT_TYPE = ? |
| 192 | 192 | ORDER BY cc.POSITION", |
| 193 | - [ $owner, $owner, $pkname, 'R' ] |
|
| 193 | + [$owner, $owner, $pkname, 'R'] |
|
| 194 | 194 | )) |
| 195 | - ->map(function ($v) { |
|
| 195 | + ->map(function($v) { |
|
| 196 | 196 | $new = []; |
| 197 | 197 | foreach ($v as $kk => $vv) { |
| 198 | 198 | $new[strtoupper($kk)] = $vv; |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | as $relation |
| 203 | 203 | ) { |
| 204 | 204 | $relations[$relation['CONSTRAINT_NAME']]['table'] = $relation['TABLE_NAME']; |
| 205 | - $relations[$relation['CONSTRAINT_NAME']]['keymap'][$primary[(int)$relation['POSITION']-1]] = $relation['COLUMN_NAME']; |
|
| 205 | + $relations[$relation['CONSTRAINT_NAME']]['keymap'][$primary[(int) $relation['POSITION'] - 1]] = $relation['COLUMN_NAME']; |
|
| 206 | 206 | } |
| 207 | 207 | foreach ($relations as $data) { |
| 208 | 208 | $rtable = $this->table($data['table'], true); // ?? $this->addTableByName($data['table'], false); |
@@ -226,9 +226,9 @@ discard block |
||
| 226 | 226 | ac.OWNER = ? AND ac.R_OWNER = ? AND ac.TABLE_NAME = ? AND ac.CONSTRAINT_TYPE = ? AND |
| 227 | 227 | cc.COLUMN_NAME IN (??) |
| 228 | 228 | ORDER BY POSITION", |
| 229 | - [ $owner, $owner, $data['table'], 'R', $columns ] |
|
| 229 | + [$owner, $owner, $data['table'], 'R', $columns] |
|
| 230 | 230 | )) |
| 231 | - ->map(function ($v) { |
|
| 231 | + ->map(function($v) { |
|
| 232 | 232 | $new = []; |
| 233 | 233 | foreach ($v as $kk => $vv) { |
| 234 | 234 | $new[strtoupper($kk)] = $vv; |
@@ -246,9 +246,9 @@ discard block |
||
| 246 | 246 | $rcolumns = Collection::from($this |
| 247 | 247 | ->query( |
| 248 | 248 | "SELECT COLUMN_NAME FROM all_cons_columns WHERE OWNER = ? AND CONSTRAINT_NAME = ? ORDER BY POSITION", |
| 249 | - [ $owner, current($foreign['keymap']) ] |
|
| 249 | + [$owner, current($foreign['keymap'])] |
|
| 250 | 250 | )) |
| 251 | - ->map(function ($v) { |
|
| 251 | + ->map(function($v) { |
|
| 252 | 252 | $new = []; |
| 253 | 253 | foreach ($v as $kk => $vv) { |
| 254 | 254 | $new[strtoupper($kk)] = $vv; |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | $relname = $foreign['table']; |
| 264 | 264 | $cntr = 1; |
| 265 | 265 | while ($definition->hasRelation($relname) || $definition->getName() == $relname) { |
| 266 | - $relname = $foreign['table'] . '_' . (++ $cntr); |
|
| 266 | + $relname = $foreign['table'].'_'.(++$cntr); |
|
| 267 | 267 | } |
| 268 | 268 | $definition->addRelation( |
| 269 | 269 | new TableRelation( |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | $relname = $data['table']; |
| 280 | 280 | $cntr = 1; |
| 281 | 281 | while ($definition->hasRelation($relname) || $definition->getName() == $relname) { |
| 282 | - $relname = $data['table'] . '_' . (++ $cntr); |
|
| 282 | + $relname = $data['table'].'_'.(++$cntr); |
|
| 283 | 283 | } |
| 284 | 284 | $definition->addRelation( |
| 285 | 285 | new TableRelation( |
@@ -303,9 +303,9 @@ discard block |
||
| 303 | 303 | LEFT JOIN all_cons_columns cc ON cc.OWNER = ac.OWNER AND cc.CONSTRAINT_NAME = ac.CONSTRAINT_NAME |
| 304 | 304 | WHERE ac.OWNER = ? AND ac.R_OWNER = ? AND ac.TABLE_NAME = ? AND ac.CONSTRAINT_TYPE = ? |
| 305 | 305 | ORDER BY cc.POSITION", |
| 306 | - [ $owner, $owner, strtoupper($table), 'R' ] |
|
| 306 | + [$owner, $owner, strtoupper($table), 'R'] |
|
| 307 | 307 | )) |
| 308 | - ->map(function ($v) { |
|
| 308 | + ->map(function($v) { |
|
| 309 | 309 | $new = []; |
| 310 | 310 | foreach ($v as $kk => $vv) { |
| 311 | 311 | $new[strtoupper($kk)] = $vv; |
@@ -321,9 +321,9 @@ discard block |
||
| 321 | 321 | $rcolumns = Collection::from($this |
| 322 | 322 | ->query( |
| 323 | 323 | "SELECT COLUMN_NAME FROM all_cons_columns WHERE OWNER = ? AND CONSTRAINT_NAME = ? ORDER BY POSITION", |
| 324 | - [ $owner, current($data['keymap']) ] |
|
| 324 | + [$owner, current($data['keymap'])] |
|
| 325 | 325 | )) |
| 326 | - ->map(function ($v) { |
|
| 326 | + ->map(function($v) { |
|
| 327 | 327 | $new = []; |
| 328 | 328 | foreach ($v as $kk => $vv) { |
| 329 | 329 | $new[strtoupper($kk)] = $vv; |
@@ -338,7 +338,7 @@ discard block |
||
| 338 | 338 | $relname = $data['table']; |
| 339 | 339 | $cntr = 1; |
| 340 | 340 | while ($definition->hasRelation($relname) || $definition->getName() == $relname) { |
| 341 | - $relname = $data['table'] . '_' . (++ $cntr); |
|
| 341 | + $relname = $data['table'].'_'.(++$cntr); |
|
| 342 | 342 | } |
| 343 | 343 | $definition->addRelation( |
| 344 | 344 | new TableRelation( |
@@ -359,7 +359,7 @@ discard block |
||
| 359 | 359 | "SELECT TABLE_NAME FROM ALL_TABLES where OWNER = ?", |
| 360 | 360 | [$this->connection['name']] |
| 361 | 361 | )) |
| 362 | - ->map(function ($v) { |
|
| 362 | + ->map(function($v) { |
|
| 363 | 363 | $new = []; |
| 364 | 364 | foreach ($v as $kk => $vv) { |
| 365 | 365 | $new[strtoupper($kk)] = $vv; |
@@ -367,7 +367,7 @@ discard block |
||
| 367 | 367 | return $new; |
| 368 | 368 | }) |
| 369 | 369 | ->pluck('TABLE_NAME') |
| 370 | - ->map(function ($v) { |
|
| 370 | + ->map(function($v) { |
|
| 371 | 371 | return $this->table($v); |
| 372 | 372 | }) |
| 373 | 373 | ->toArray(); |
@@ -22,7 +22,7 @@ |
||
| 22 | 22 | parse_str($temp[1], $connection['opts']); |
| 23 | 23 | $connection['name'] = $temp[0]; |
| 24 | 24 | if (!is_file($connection['name']) && is_file('/'.$connection['name'])) { |
| 25 | - $connection['name'] = '/'.$connection['name']; |
|
| 25 | + $connection['name'] = '/'.$connection['name']; |
|
| 26 | 26 | } |
| 27 | 27 | $this->connection = $connection; |
| 28 | 28 | } |