| @@ 526-555 (lines=30) @@ | ||
| 523 | * @param string $tableName Table Name |
|
| 524 | * @return array |
|
| 525 | */ |
|
| 526 | protected function getIndexes($tableName) |
|
| 527 | { |
|
| 528 | $indexes = []; |
|
| 529 | $sql = "SELECT |
|
| 530 | i.relname AS index_name, |
|
| 531 | a.attname AS column_name |
|
| 532 | FROM |
|
| 533 | pg_class t, |
|
| 534 | pg_class i, |
|
| 535 | pg_index ix, |
|
| 536 | pg_attribute a |
|
| 537 | WHERE |
|
| 538 | t.oid = ix.indrelid |
|
| 539 | AND i.oid = ix.indexrelid |
|
| 540 | AND a.attrelid = t.oid |
|
| 541 | AND a.attnum = ANY(ix.indkey) |
|
| 542 | AND t.relkind = 'r' |
|
| 543 | AND t.relname = '$tableName' |
|
| 544 | ORDER BY |
|
| 545 | t.relname, |
|
| 546 | i.relname;"; |
|
| 547 | $rows = $this->fetchAll($sql); |
|
| 548 | foreach ($rows as $row) { |
|
| 549 | if (!isset($indexes[$row['index_name']])) { |
|
| 550 | $indexes[$row['index_name']] = ['columns' => []]; |
|
| 551 | } |
|
| 552 | $indexes[$row['index_name']]['columns'][] = strtolower($row['column_name']); |
|
| 553 | } |
|
| 554 | ||
| 555 | return $indexes; |
|
| 556 | } |
|
| 557 | ||
| 558 | /** |
|
| @@ 449-460 (lines=12) @@ | ||
| 446 | * |
|
| 447 | * @return array |
|
| 448 | */ |
|
| 449 | protected function getIndexes( $tableName ) { |
|
| 450 | $indexes = []; |
|
| 451 | $rows = $this->fetchAll( sprintf( 'SHOW INDEXES FROM %s', $this->quoteTableName( $tableName ) ) ); |
|
| 452 | foreach ( $rows as $row ) { |
|
| 453 | if ( ! isset( $indexes[ $row['Key_name'] ] ) ) { |
|
| 454 | $indexes[ $row['Key_name'] ] = [ 'columns' => [] ]; |
|
| 455 | } |
|
| 456 | $indexes[ $row['Key_name'] ]['columns'][] = strtolower( $row['Column_name'] ); |
|
| 457 | } |
|
| 458 | ||
| 459 | return $indexes; |
|
| 460 | } |
|
| 461 | ||
| 462 | /** |
|
| 463 | * {@inheritdoc} |
|