| @@ 469-480 (lines=12) @@ | ||
| 466 | * @param string $tableName Table Name |
|
| 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 | /** |
|
| @@ 510-539 (lines=30) @@ | ||
| 507 | * @param string $tableName Table Name |
|
| 508 | * @return array |
|
| 509 | */ |
|
| 510 | protected function getIndexes($tableName) |
|
| 511 | { |
|
| 512 | $indexes = []; |
|
| 513 | $sql = "SELECT |
|
| 514 | i.relname AS index_name, |
|
| 515 | a.attname AS column_name |
|
| 516 | FROM |
|
| 517 | pg_class t, |
|
| 518 | pg_class i, |
|
| 519 | pg_index ix, |
|
| 520 | pg_attribute a |
|
| 521 | WHERE |
|
| 522 | t.oid = ix.indrelid |
|
| 523 | AND i.oid = ix.indexrelid |
|
| 524 | AND a.attrelid = t.oid |
|
| 525 | AND a.attnum = ANY(ix.indkey) |
|
| 526 | AND t.relkind = 'r' |
|
| 527 | AND t.relname = '$tableName' |
|
| 528 | ORDER BY |
|
| 529 | t.relname, |
|
| 530 | i.relname;"; |
|
| 531 | $rows = $this->fetchAll($sql); |
|
| 532 | foreach ($rows as $row) { |
|
| 533 | if (!isset($indexes[$row['index_name']])) { |
|
| 534 | $indexes[$row['index_name']] = ['columns' => []]; |
|
| 535 | } |
|
| 536 | $indexes[$row['index_name']]['columns'][] = strtolower($row['column_name']); |
|
| 537 | } |
|
| 538 | ||
| 539 | return $indexes; |
|
| 540 | } |
|
| 541 | ||
| 542 | /** |
|