| @@ 469-480 (lines=12) @@ | ||
| 466 | * |
|
| 467 | * @return array |
|
| 468 | */ |
|
| 469 | protected function getIndexes($tableName) |
|
| 470 | { |
|
| 471 | $indexes = []; |
|
| 472 | $rows = $this->fetchAll(sprintf('SHOW INDEXES FROM %s', $this->quoteTableName($tableName))); |
|
| 473 | foreach ($rows as $row) { |
|
| 474 | if (! isset($indexes[$row['Key_name']])) { |
|
| 475 | $indexes[$row['Key_name']] = [ 'columns' => [] ]; |
|
| 476 | } |
|
| 477 | $indexes[$row['Key_name']]['columns'][] = strtolower($row['Column_name']); |
|
| 478 | } |
|
| 479 | ||
| 480 | return $indexes; |
|
| 481 | } |
|
| 482 | ||
| 483 | /** |
|
| @@ 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 | /** |
|