| @@ 465-476 (lines=12) @@ | ||
| 462 | * @param string $tableName Table Name |
|
| 463 | * @return array |
|
| 464 | */ |
|
| 465 | protected function getIndexes($tableName) |
|
| 466 | { |
|
| 467 | $indexes = []; |
|
| 468 | $rows = $this->fetchAll(sprintf('SHOW INDEXES FROM %s', $this->quoteTableName($tableName))); |
|
| 469 | foreach ($rows as $row) { |
|
| 470 | if (!isset($indexes[$row['Key_name']])) { |
|
| 471 | $indexes[$row['Key_name']] = ['columns' => []]; |
|
| 472 | } |
|
| 473 | $indexes[$row['Key_name']]['columns'][] = strtolower($row['Column_name']); |
|
| 474 | } |
|
| 475 | ||
| 476 | return $indexes; |
|
| 477 | } |
|
| 478 | ||
| 479 | /** |
|
| @@ 509-538 (lines=30) @@ | ||
| 506 | * @param string $tableName Table Name |
|
| 507 | * @return array |
|
| 508 | */ |
|
| 509 | protected function getIndexes($tableName) |
|
| 510 | { |
|
| 511 | $indexes = []; |
|
| 512 | $sql = "SELECT |
|
| 513 | i.relname AS index_name, |
|
| 514 | a.attname AS column_name |
|
| 515 | FROM |
|
| 516 | pg_class t, |
|
| 517 | pg_class i, |
|
| 518 | pg_index ix, |
|
| 519 | pg_attribute a |
|
| 520 | WHERE |
|
| 521 | t.oid = ix.indrelid |
|
| 522 | AND i.oid = ix.indexrelid |
|
| 523 | AND a.attrelid = t.oid |
|
| 524 | AND a.attnum = ANY(ix.indkey) |
|
| 525 | AND t.relkind = 'r' |
|
| 526 | AND t.relname = '$tableName' |
|
| 527 | ORDER BY |
|
| 528 | t.relname, |
|
| 529 | i.relname;"; |
|
| 530 | $rows = $this->fetchAll($sql); |
|
| 531 | foreach ($rows as $row) { |
|
| 532 | if (!isset($indexes[$row['index_name']])) { |
|
| 533 | $indexes[$row['index_name']] = ['columns' => []]; |
|
| 534 | } |
|
| 535 | $indexes[$row['index_name']]['columns'][] = strtolower($row['column_name']); |
|
| 536 | } |
|
| 537 | ||
| 538 | return $indexes; |
|
| 539 | } |
|
| 540 | ||
| 541 | /** |
|