| @@ 461-472 (lines=12) @@ | ||
| 458 | * @param string $tableName Table Name | |
| 459 | * @return array | |
| 460 | */ | |
| 461 | protected function getIndexes($tableName) | |
| 462 |     { | |
| 463 | $indexes = []; | |
| 464 |         $rows = $this->fetchAll(sprintf('SHOW INDEXES FROM %s', $this->quoteTableName($tableName))); | |
| 465 |         foreach ($rows as $row) { | |
| 466 |             if (!isset($indexes[$row['Key_name']])) { | |
| 467 | $indexes[$row['Key_name']] = ['columns' => []]; | |
| 468 | } | |
| 469 | $indexes[$row['Key_name']]['columns'][] = strtolower($row['Column_name']); | |
| 470 | } | |
| 471 | ||
| 472 | return $indexes; | |
| 473 | } | |
| 474 | ||
| 475 | /** | |
| @@ 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 | /** | |