| @@ 332-359 (lines=28) @@ | ||
| 329 | /** |
|
| 330 | * {@inheritdoc} |
|
| 331 | */ |
|
| 332 | public function getColumns($tableName) |
|
| 333 | { |
|
| 334 | $columns = []; |
|
| 335 | $rows = $this->fetchAll(sprintf('SHOW COLUMNS FROM %s', $this->quoteTableName($tableName))); |
|
| 336 | foreach ($rows as $columnInfo) { |
|
| 337 | $phinxType = $this->getPhinxType($columnInfo['Type']); |
|
| 338 | ||
| 339 | $column = new Column(); |
|
| 340 | $column->setName($columnInfo['Field']) |
|
| 341 | ->setNull($columnInfo['Null'] !== 'NO') |
|
| 342 | ->setDefault($columnInfo['Default']) |
|
| 343 | ->setType($phinxType['name']) |
|
| 344 | ->setSigned(strpos($columnInfo['Type'], 'unsigned') === false) |
|
| 345 | ->setLimit($phinxType['limit']); |
|
| 346 | ||
| 347 | if ($columnInfo['Extra'] === 'auto_increment') { |
|
| 348 | $column->setIdentity(true); |
|
| 349 | } |
|
| 350 | ||
| 351 | if (isset($phinxType['values'])) { |
|
| 352 | $column->setValues($phinxType['values']); |
|
| 353 | } |
|
| 354 | ||
| 355 | $columns[] = $column; |
|
| 356 | } |
|
| 357 | ||
| 358 | return $columns; |
|
| 359 | } |
|
| 360 | ||
| 361 | /** |
|
| 362 | * {@inheritdoc} |
|
| @@ 311-344 (lines=34) @@ | ||
| 308 | /** |
|
| 309 | * {@inheritdoc} |
|
| 310 | */ |
|
| 311 | public function getColumns($tableName) |
|
| 312 | { |
|
| 313 | $columns = []; |
|
| 314 | $sql = sprintf( |
|
| 315 | "SELECT column_name, data_type, is_identity, is_nullable, |
|
| 316 | column_default, character_maximum_length, numeric_precision, numeric_scale |
|
| 317 | FROM information_schema.columns |
|
| 318 | WHERE table_name ='%s'", |
|
| 319 | $tableName |
|
| 320 | ); |
|
| 321 | $columnsInfo = $this->fetchAll($sql); |
|
| 322 | ||
| 323 | foreach ($columnsInfo as $columnInfo) { |
|
| 324 | $column = new Column(); |
|
| 325 | $column->setName($columnInfo['column_name']) |
|
| 326 | ->setType($this->getPhinxType($columnInfo['data_type'])) |
|
| 327 | ->setNull($columnInfo['is_nullable'] === 'YES') |
|
| 328 | ->setDefault($columnInfo['column_default']) |
|
| 329 | ->setIdentity($columnInfo['is_identity'] === 'YES') |
|
| 330 | ->setPrecision($columnInfo['numeric_precision']) |
|
| 331 | ->setScale($columnInfo['numeric_scale']); |
|
| 332 | ||
| 333 | if (preg_match('/\bwith time zone$/', $columnInfo['data_type'])) { |
|
| 334 | $column->setTimezone(true); |
|
| 335 | } |
|
| 336 | ||
| 337 | if (isset($columnInfo['character_maximum_length'])) { |
|
| 338 | $column->setLimit($columnInfo['character_maximum_length']); |
|
| 339 | } |
|
| 340 | $columns[] = $column; |
|
| 341 | } |
|
| 342 | ||
| 343 | return $columns; |
|
| 344 | } |
|
| 345 | ||
| 346 | /** |
|
| 347 | * {@inheritdoc} |
|