| @@ 483-494 (lines=12) @@ | ||
| 480 | * @param string $tableName Table Name |
|
| 481 | * @return array |
|
| 482 | */ |
|
| 483 | protected function getIndexes($tableName) |
|
| 484 | { |
|
| 485 | $indexes = []; |
|
| 486 | $rows = $this->fetchAll(sprintf('SHOW INDEXES FROM %s', $this->quoteTableName($tableName))); |
|
| 487 | foreach ($rows as $row) { |
|
| 488 | if (!isset($indexes[$row['Key_name']])) { |
|
| 489 | $indexes[$row['Key_name']] = ['columns' => []]; |
|
| 490 | } |
|
| 491 | $indexes[$row['Key_name']]['columns'][] = strtolower($row['Column_name']); |
|
| 492 | } |
|
| 493 | ||
| 494 | return $indexes; |
|
| 495 | } |
|
| 496 | ||
| 497 | /** |
|
| @@ 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 | /** |
|