@@ -32,7 +32,7 @@ |
||
32 | 32 | /** |
33 | 33 | * Returns a single column from the next row of a result set. |
34 | 34 | * @param integer $columnIndex zero-based column index |
35 | - * @return mixed the column of the current row, false if no more rows available |
|
35 | + * @return string|false the column of the current row, false if no more rows available |
|
36 | 36 | */ |
37 | 37 | public function readColumn($columnIndex) |
38 | 38 | { |
@@ -118,6 +118,7 @@ discard block |
||
118 | 118 | |
119 | 119 | /** |
120 | 120 | * @inheritdoc |
121 | + * @param string $name |
|
121 | 122 | */ |
122 | 123 | public function quoteSimpleColumnName($name) |
123 | 124 | { |
@@ -142,6 +143,8 @@ discard block |
||
142 | 143 | |
143 | 144 | /** |
144 | 145 | * @inheritdoc |
146 | + * @param TableSchema $table |
|
147 | + * @param string $name |
|
145 | 148 | */ |
146 | 149 | protected function resolveTableNames($table, $name) |
147 | 150 | { |
@@ -216,6 +219,7 @@ discard block |
||
216 | 219 | |
217 | 220 | /** |
218 | 221 | * @inheritdoc |
222 | + * @param TableSchema $table |
|
219 | 223 | */ |
220 | 224 | protected function findColumns($table) |
221 | 225 | { |
@@ -306,6 +310,7 @@ discard block |
||
306 | 310 | |
307 | 311 | /** |
308 | 312 | * @inheritdoc |
313 | + * @param TableSchema $table |
|
309 | 314 | */ |
310 | 315 | protected function findConstraints($table) |
311 | 316 | { |
@@ -146,12 +146,12 @@ discard block |
||
146 | 146 | protected function resolveTableNames($table, $name) |
147 | 147 | { |
148 | 148 | $parts = explode('.', str_replace('"', '', $name)); |
149 | - if (isset($parts[1])) { |
|
150 | - $table->schemaName = $parts[0]; |
|
151 | - $table->name = $parts[1]; |
|
149 | + if (isset($parts[ 1 ])) { |
|
150 | + $table->schemaName = $parts[ 0 ]; |
|
151 | + $table->name = $parts[ 1 ]; |
|
152 | 152 | $table->fullName = $table->schemaName . '.' . $table->name; |
153 | 153 | } else { |
154 | - $table->fullName = $table->name = $parts[0]; |
|
154 | + $table->fullName = $table->name = $parts[ 0 ]; |
|
155 | 155 | } |
156 | 156 | } |
157 | 157 | |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | ]; |
174 | 174 | $type = gettype($data); |
175 | 175 | |
176 | - return isset($typeMap[$type]) ? $typeMap[$type] : PDO::PARAM_STR; |
|
176 | + return isset($typeMap[ $type ]) ? $typeMap[ $type ] : PDO::PARAM_STR; |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | /** |
@@ -183,24 +183,24 @@ discard block |
||
183 | 183 | { |
184 | 184 | $column = $this->createColumnSchema(); |
185 | 185 | |
186 | - $column->name = $info['name']; |
|
187 | - $column->dbType = $info['dbtype']; |
|
188 | - $column->defaultValue = isset($info['defaultvalue']) ? trim($info['defaultvalue'], "''") : null; |
|
189 | - $column->scale = (int) $info['scale']; |
|
190 | - $column->size = (int) $info['size']; |
|
191 | - $column->precision = (int) $info['size']; |
|
192 | - $column->allowNull = $info['allownull'] === '1'; |
|
193 | - $column->isPrimaryKey = $info['isprimarykey'] === '1'; |
|
194 | - $column->autoIncrement = $info['autoincrement'] === '1'; |
|
186 | + $column->name = $info[ 'name' ]; |
|
187 | + $column->dbType = $info[ 'dbtype' ]; |
|
188 | + $column->defaultValue = isset($info[ 'defaultvalue' ]) ? trim($info[ 'defaultvalue' ], "''") : null; |
|
189 | + $column->scale = (int) $info[ 'scale' ]; |
|
190 | + $column->size = (int) $info[ 'size' ]; |
|
191 | + $column->precision = (int) $info[ 'size' ]; |
|
192 | + $column->allowNull = $info[ 'allownull' ] === '1'; |
|
193 | + $column->isPrimaryKey = $info[ 'isprimarykey' ] === '1'; |
|
194 | + $column->autoIncrement = $info[ 'autoincrement' ] === '1'; |
|
195 | 195 | $column->unsigned = false; |
196 | - $column->type = $this->typeMap[strtolower($info['dbtype'])]; |
|
196 | + $column->type = $this->typeMap[ strtolower($info[ 'dbtype' ]) ]; |
|
197 | 197 | $column->enumValues = null; |
198 | - $column->comment = isset($info['comment']) ? $info['comment'] : null; |
|
198 | + $column->comment = isset($info[ 'comment' ]) ? $info[ 'comment' ] : null; |
|
199 | 199 | |
200 | - if (preg_match('/(varchar|character|clob|graphic|binary|blob)/i', $info['dbtype'])) { |
|
201 | - $column->dbType .= '(' . $info['size'] . ')'; |
|
202 | - } elseif (preg_match('/(decimal|double|real)/i', $info['dbtype'])) { |
|
203 | - $column->dbType .= '(' . $info['size'] . ',' . $info['scale'] . ')'; |
|
200 | + if (preg_match('/(varchar|character|clob|graphic|binary|blob)/i', $info[ 'dbtype' ])) { |
|
201 | + $column->dbType .= '(' . $info[ 'size' ] . ')'; |
|
202 | + } elseif (preg_match('/(decimal|double|real)/i', $info[ 'dbtype' ])) { |
|
203 | + $column->dbType .= '(' . $info[ 'size' ] . ',' . $info[ 'scale' ] . ')'; |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | if ($column->defaultValue) { |
@@ -274,11 +274,11 @@ discard block |
||
274 | 274 | |
275 | 275 | $command = $this->db->createCommand($sql); |
276 | 276 | $command->bindValue(':table', $table->name); |
277 | - if($this->db->isISeries){ |
|
277 | + if ($this->db->isISeries) { |
|
278 | 278 | $command->bindValue(':schema', $this->db->defaultSchema); |
279 | 279 | $command->bindValue(':table1', $table->name); |
280 | 280 | |
281 | - }else { |
|
281 | + } else { |
|
282 | 282 | if (isset($table->schemaName)) { |
283 | 283 | $command->bindValue(':schema', $table->schemaName); |
284 | 284 | } |
@@ -293,9 +293,9 @@ discard block |
||
293 | 293 | $info = array_change_key_case($info, CASE_LOWER); |
294 | 294 | } |
295 | 295 | $column = $this->loadColumnSchema($info); |
296 | - $table->columns[$column->name] = $column; |
|
296 | + $table->columns[ $column->name ] = $column; |
|
297 | 297 | if ($column->isPrimaryKey) { |
298 | - $table->primaryKey[] = $column->name; |
|
298 | + $table->primaryKey[ ] = $column->name; |
|
299 | 299 | if ($column->autoIncrement) { |
300 | 300 | $table->sequenceName = $column->name; |
301 | 301 | } |
@@ -351,31 +351,31 @@ discard block |
||
351 | 351 | } |
352 | 352 | $command = $this->db->createCommand($sql); |
353 | 353 | $command->bindValue(':table', $table->name); |
354 | - if($this->db->isISeries){ |
|
354 | + if ($this->db->isISeries) { |
|
355 | 355 | $command->bindValue(':schema', $this->db->defaultSchema); |
356 | - }else { |
|
356 | + } else { |
|
357 | 357 | if (isset($table->schemaName)) { |
358 | 358 | $command->bindValue(':schema', $table->schemaName); |
359 | 359 | } |
360 | 360 | } |
361 | 361 | |
362 | 362 | $results = $command->queryAll(); |
363 | - $foreignKeys = []; |
|
363 | + $foreignKeys = [ ]; |
|
364 | 364 | foreach ($results as $result) { |
365 | 365 | if ($this->db->slavePdo->getAttribute(PDO::ATTR_CASE) !== PDO::CASE_LOWER) { |
366 | 366 | $result = array_change_key_case($result, CASE_LOWER); |
367 | 367 | } |
368 | - $tablename = $result['tablename']; |
|
369 | - $fk = $result['fk']; |
|
370 | - $pk = $result['pk']; |
|
371 | - $foreignKeys[$tablename][$fk] = $pk; |
|
368 | + $tablename = $result[ 'tablename' ]; |
|
369 | + $fk = $result[ 'fk' ]; |
|
370 | + $pk = $result[ 'pk' ]; |
|
371 | + $foreignKeys[ $tablename ][ $fk ] = $pk; |
|
372 | 372 | } |
373 | 373 | foreach ($foreignKeys as $tablename => $keymap) { |
374 | - $constraint = [$tablename]; |
|
374 | + $constraint = [ $tablename ]; |
|
375 | 375 | foreach ($keymap as $fk => $pk) { |
376 | - $constraint[$fk] = $pk; |
|
376 | + $constraint[ $fk ] = $pk; |
|
377 | 377 | } |
378 | - $table->foreignKeys[] = $constraint; |
|
378 | + $table->foreignKeys[ ] = $constraint; |
|
379 | 379 | } |
380 | 380 | } |
381 | 381 | |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | AND qsys2.syscst.table_schema = :schema |
401 | 401 | ORDER BY qsys2.syskeycst.column_position |
402 | 402 | SQL; |
403 | - }else { |
|
403 | + } else { |
|
404 | 404 | $sql = <<<SQL |
405 | 405 | SELECT |
406 | 406 | i.indname AS indexname, |
@@ -422,20 +422,20 @@ discard block |
||
422 | 422 | $command = $this->db->createCommand($sql); |
423 | 423 | $command->bindValue(':table', $table->name); |
424 | 424 | |
425 | - if($this->db->isISeries){ |
|
425 | + if ($this->db->isISeries) { |
|
426 | 426 | $command->bindValue(':schema', $this->db->defaultSchema); |
427 | - }else{ |
|
427 | + } else { |
|
428 | 428 | if (isset($table->schemaName)) { |
429 | 429 | $command->bindValue(':schema', $table->schemaName); |
430 | 430 | } |
431 | 431 | } |
432 | 432 | $results = $command->queryAll(); |
433 | - $indexes = []; |
|
433 | + $indexes = [ ]; |
|
434 | 434 | foreach ($results as $result) { |
435 | 435 | if ($this->db->slavePdo->getAttribute(PDO::ATTR_CASE) !== PDO::CASE_LOWER) { |
436 | 436 | $result = array_change_key_case($result, CASE_LOWER); |
437 | 437 | } |
438 | - $indexes[$result['indexname']][] = $result['column']; |
|
438 | + $indexes[ $result[ 'indexname' ] ][ ] = $result[ 'column' ]; |
|
439 | 439 | } |
440 | 440 | return $indexes; |
441 | 441 | } |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | { |
448 | 448 | |
449 | 449 | if ($schema === '' && $this->db->isISeries) { |
450 | - $schema= $this->db->defaultSchema; |
|
450 | + $schema = $this->db->defaultSchema; |
|
451 | 451 | } |
452 | 452 | |
453 | 453 | if ($this->db->isISeries) { |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | AND TABLE_SCHEMA = :schema |
460 | 460 | ORDER BY TABLE_NAME |
461 | 461 | SQL; |
462 | - }else { |
|
462 | + } else { |
|
463 | 463 | |
464 | 464 | $sql = <<<SQL |
465 | 465 | SELECT |
@@ -538,7 +538,7 @@ discard block |
||
538 | 538 | $this->db->createCommand($sql)->execute(); |
539 | 539 | } catch (\Exception $ex) { |
540 | 540 | // Do not throw error on table which doesn't exist |
541 | - if (!(isset($ex->errorInfo[1]) && $ex->errorInfo[1] === -2211)) { |
|
541 | + if (!(isset($ex->errorInfo[ 1 ]) && $ex->errorInfo[ 1 ] === -2211)) { |
|
542 | 542 | throw new \Exception($ex->getMessage(), $ex->getCode(), $ex->getPrevious()); |
543 | 543 | } |
544 | 544 | } |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | $command->bindValue(':schema', $this->db->defaultSchema); |
279 | 279 | $command->bindValue(':table1', $table->name); |
280 | 280 | |
281 | - }else { |
|
281 | + } else { |
|
282 | 282 | if (isset($table->schemaName)) { |
283 | 283 | $command->bindValue(':schema', $table->schemaName); |
284 | 284 | } |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | $command->bindValue(':table', $table->name); |
354 | 354 | if($this->db->isISeries){ |
355 | 355 | $command->bindValue(':schema', $this->db->defaultSchema); |
356 | - }else { |
|
356 | + } else { |
|
357 | 357 | if (isset($table->schemaName)) { |
358 | 358 | $command->bindValue(':schema', $table->schemaName); |
359 | 359 | } |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | AND qsys2.syscst.table_schema = :schema |
401 | 401 | ORDER BY qsys2.syskeycst.column_position |
402 | 402 | SQL; |
403 | - }else { |
|
403 | + } else { |
|
404 | 404 | $sql = <<<SQL |
405 | 405 | SELECT |
406 | 406 | i.indname AS indexname, |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | |
425 | 425 | if($this->db->isISeries){ |
426 | 426 | $command->bindValue(':schema', $this->db->defaultSchema); |
427 | - }else{ |
|
427 | + } else{ |
|
428 | 428 | if (isset($table->schemaName)) { |
429 | 429 | $command->bindValue(':schema', $table->schemaName); |
430 | 430 | } |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | AND TABLE_SCHEMA = :schema |
460 | 460 | ORDER BY TABLE_NAME |
461 | 461 | SQL; |
462 | - }else { |
|
462 | + } else { |
|
463 | 463 | |
464 | 464 | $sql = <<<SQL |
465 | 465 | SELECT |
@@ -54,7 +54,7 @@ |
||
54 | 54 | 'timestmp' => self::TYPE_TIMESTAMP |
55 | 55 | ]; |
56 | 56 | |
57 | - /** |
|
57 | + /** |
|
58 | 58 | * @inheritdoc |
59 | 59 | */ |
60 | 60 | public function createQueryBuilder() |
@@ -56,14 +56,14 @@ discard block |
||
56 | 56 | { |
57 | 57 | $table = $this->db->getTableSchema($tableName); |
58 | 58 | |
59 | - if ($table !== null && isset($table->columns[$table->sequenceName])) { |
|
59 | + if ($table !== null && isset($table->columns[ $table->sequenceName ])) { |
|
60 | 60 | if ($value === null) { |
61 | - $sql = 'SELECT MAX("'. $table->sequenceName .'") FROM "'. $tableName . '"'; |
|
61 | + $sql = 'SELECT MAX("' . $table->sequenceName . '") FROM "' . $tableName . '"'; |
|
62 | 62 | $value = $this->db->createCommand($sql)->queryScalar() + 1; |
63 | 63 | } else { |
64 | 64 | $value = (int) $value; |
65 | 65 | } |
66 | - return 'ALTER TABLE "' . $tableName . '" ALTER COLUMN "'.$table->sequenceName.'" RESTART WITH ' . $value; |
|
66 | + return 'ALTER TABLE "' . $tableName . '" ALTER COLUMN "' . $table->sequenceName . '" RESTART WITH ' . $value; |
|
67 | 67 | } elseif ($table === null) { |
68 | 68 | throw new InvalidParamException("Table not found: $tableName"); |
69 | 69 | } else { |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | public function checkIntegrity($check = true, $schema = '', $table = '') |
84 | 84 | { |
85 | 85 | if ($table) { |
86 | - $tableNames = [$table]; |
|
86 | + $tableNames = [ $table ]; |
|
87 | 87 | } else { |
88 | 88 | //Return only tables |
89 | 89 | $sql = "SELECT t.tabname FROM syscat.tables AS t" |
@@ -112,13 +112,13 @@ discard block |
||
112 | 112 | return ''; |
113 | 113 | } |
114 | 114 | |
115 | - $quotedTableNames = []; |
|
115 | + $quotedTableNames = [ ]; |
|
116 | 116 | foreach ($tableNames as $tableName) { |
117 | - $quotedTableNames[] = $this->db->quoteTableName($tableName) . ($check? '' : ' ALL'); |
|
117 | + $quotedTableNames[ ] = $this->db->quoteTableName($tableName) . ($check ? '' : ' ALL'); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | $enable = $check ? 'CHECKED' : 'UNCHECKED'; |
121 | - return 'SET INTEGRITY FOR ' . implode(', ', $quotedTableNames) . ' IMMEDIATE ' . $enable. ';'; |
|
121 | + return 'SET INTEGRITY FOR ' . implode(', ', $quotedTableNames) . ' IMMEDIATE ' . $enable . ';'; |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -131,22 +131,22 @@ discard block |
||
131 | 131 | $sql = str_replace(':query', $sql, $limitOffsetStatment); |
132 | 132 | |
133 | 133 | //convert "item"."id" to "id" to use in OVER() |
134 | - $newOrderBy = []; |
|
134 | + $newOrderBy = [ ]; |
|
135 | 135 | |
136 | - if(!empty($orderBy)){ |
|
136 | + if (!empty($orderBy)) { |
|
137 | 137 | foreach ($orderBy as $name => $direction) { |
138 | - if(is_string($name)){ |
|
138 | + if (is_string($name)) { |
|
139 | 139 | $e = explode('.', $name); |
140 | 140 | $name = array_pop($e); |
141 | 141 | } |
142 | - $newOrderBy[$name] = $direction; |
|
142 | + $newOrderBy[ $name ] = $direction; |
|
143 | 143 | } |
144 | 144 | } |
145 | 145 | |
146 | 146 | $orderByStatment = $this->buildOrderBy($newOrderBy); |
147 | 147 | |
148 | - $sql = str_replace(':order', $orderByStatment,$sql); |
|
149 | - }else{ |
|
148 | + $sql = str_replace(':order', $orderByStatment, $sql); |
|
149 | + } else { |
|
150 | 150 | $orderByStatment = $this->buildOrderBy($orderBy); |
151 | 151 | if ($orderByStatment !== '') { |
152 | 152 | $sql .= $this->separator . $orderByStatment; |
@@ -190,23 +190,23 @@ discard block |
||
190 | 190 | */ |
191 | 191 | protected function buildCompositeInCondition($operator, $columns, $values, &$params) |
192 | 192 | { |
193 | - $vss = []; |
|
193 | + $vss = [ ]; |
|
194 | 194 | foreach ($values as $value) { |
195 | - $vs = []; |
|
195 | + $vs = [ ]; |
|
196 | 196 | foreach ($columns as $column) { |
197 | - if (isset($value[$column])) { |
|
197 | + if (isset($value[ $column ])) { |
|
198 | 198 | $phName = self::PARAM_PREFIX . count($params); |
199 | - $params[$phName] = $value[$column]; |
|
200 | - $vs[] = $phName; |
|
199 | + $params[ $phName ] = $value[ $column ]; |
|
200 | + $vs[ ] = $phName; |
|
201 | 201 | } else { |
202 | - $vs[] = 'NULL'; |
|
202 | + $vs[ ] = 'NULL'; |
|
203 | 203 | } |
204 | 204 | } |
205 | - $vss[] = 'select ' . implode(', ', $vs) . ' from SYSIBM.SYSDUMMY1'; |
|
205 | + $vss[ ] = 'select ' . implode(', ', $vs) . ' from SYSIBM.SYSDUMMY1'; |
|
206 | 206 | } |
207 | 207 | foreach ($columns as $i => $column) { |
208 | 208 | if (strpos($column, '(') === false) { |
209 | - $columns[$i] = $this->db->quoteColumnName($column); |
|
209 | + $columns[ $i ] = $this->db->quoteColumnName($column); |
|
210 | 210 | } |
211 | 211 | } |
212 | 212 | |
@@ -222,21 +222,21 @@ discard block |
||
222 | 222 | if (($tableSchema = $schema->getTableSchema($table)) !== null) { |
223 | 223 | $columnSchemas = $tableSchema->columns; |
224 | 224 | } else { |
225 | - $columnSchemas = []; |
|
225 | + $columnSchemas = [ ]; |
|
226 | 226 | } |
227 | - $names = []; |
|
228 | - $placeholders = []; |
|
227 | + $names = [ ]; |
|
228 | + $placeholders = [ ]; |
|
229 | 229 | foreach ($columns as $name => $value) { |
230 | - $names[] = $schema->quoteColumnName($name); |
|
230 | + $names[ ] = $schema->quoteColumnName($name); |
|
231 | 231 | if ($value instanceof Expression) { |
232 | - $placeholders[] = $value->expression; |
|
232 | + $placeholders[ ] = $value->expression; |
|
233 | 233 | foreach ($value->params as $n => $v) { |
234 | - $params[$n] = $v; |
|
234 | + $params[ $n ] = $v; |
|
235 | 235 | } |
236 | 236 | } else { |
237 | 237 | $phName = self::PARAM_PREFIX . count($params); |
238 | - $placeholders[] = $phName; |
|
239 | - $params[$phName] = !is_array($value) && isset($columnSchemas[$name]) ? $columnSchemas[$name]->dbTypecast($value) : $value; |
|
238 | + $placeholders[ ] = $phName; |
|
239 | + $params[ $phName ] = !is_array($value) && isset($columnSchemas[ $name ]) ? $columnSchemas[ $name ]->dbTypecast($value) : $value; |
|
240 | 240 | } |
241 | 241 | } |
242 | 242 |
@@ -146,7 +146,7 @@ |
||
146 | 146 | $orderByStatment = $this->buildOrderBy($newOrderBy); |
147 | 147 | |
148 | 148 | $sql = str_replace(':order', $orderByStatment,$sql); |
149 | - }else{ |
|
149 | + } else{ |
|
150 | 150 | $orderByStatment = $this->buildOrderBy($orderBy); |
151 | 151 | if ($orderByStatment !== '') { |
152 | 152 | $sql .= $this->separator . $orderByStatment; |
@@ -73,11 +73,11 @@ |
||
73 | 73 | { |
74 | 74 | parent::initConnection(); |
75 | 75 | |
76 | - if($this->defaultSchema){ |
|
76 | + if ($this->defaultSchema) { |
|
77 | 77 | $this->pdo->exec('SET CURRENT SCHEMA ' . $this->pdo->quote($this->defaultSchema)); |
78 | 78 | } |
79 | 79 | |
80 | - if($this->isISeries === null){ |
|
80 | + if ($this->isISeries === null) { |
|
81 | 81 | try { |
82 | 82 | $stmt = $this->pdo->query('SELECT * FROM QSYS2.SYSTABLES FETCH FIRST 1 ROW ONLY'); |
83 | 83 | $this->isIseries = boolval($stmt); |