| @@ 485-496 (lines=12) @@ | ||
| 482 | * @param string $tableName Table Name |
|
| 483 | * @return array |
|
| 484 | */ |
|
| 485 | protected function getIndexes($tableName) |
|
| 486 | { |
|
| 487 | $indexes = []; |
|
| 488 | $rows = $this->fetchAll(sprintf('SHOW INDEXES FROM %s', $this->quoteTableName($tableName))); |
|
| 489 | foreach ($rows as $row) { |
|
| 490 | if (!isset($indexes[$row['Key_name']])) { |
|
| 491 | $indexes[$row['Key_name']] = ['columns' => []]; |
|
| 492 | } |
|
| 493 | $indexes[$row['Key_name']]['columns'][] = strtolower($row['Column_name']); |
|
| 494 | } |
|
| 495 | ||
| 496 | return $indexes; |
|
| 497 | } |
|
| 498 | ||
| 499 | /** |
|
| @@ 500-529 (lines=30) @@ | ||
| 497 | * @param string $tableName Table Name |
|
| 498 | * @return array |
|
| 499 | */ |
|
| 500 | protected function getIndexes($tableName) |
|
| 501 | { |
|
| 502 | $indexes = []; |
|
| 503 | $sql = "SELECT |
|
| 504 | i.relname AS index_name, |
|
| 505 | a.attname AS column_name |
|
| 506 | FROM |
|
| 507 | pg_class t, |
|
| 508 | pg_class i, |
|
| 509 | pg_index ix, |
|
| 510 | pg_attribute a |
|
| 511 | WHERE |
|
| 512 | t.oid = ix.indrelid |
|
| 513 | AND i.oid = ix.indexrelid |
|
| 514 | AND a.attrelid = t.oid |
|
| 515 | AND a.attnum = ANY(ix.indkey) |
|
| 516 | AND t.relkind = 'r' |
|
| 517 | AND t.relname = '$tableName' |
|
| 518 | ORDER BY |
|
| 519 | t.relname, |
|
| 520 | i.relname;"; |
|
| 521 | $rows = $this->fetchAll($sql); |
|
| 522 | foreach ($rows as $row) { |
|
| 523 | if (!isset($indexes[$row['index_name']])) { |
|
| 524 | $indexes[$row['index_name']] = ['columns' => []]; |
|
| 525 | } |
|
| 526 | $indexes[$row['index_name']]['columns'][] = strtolower($row['column_name']); |
|
| 527 | } |
|
| 528 | ||
| 529 | return $indexes; |
|
| 530 | } |
|
| 531 | ||
| 532 | /** |
|