@@ 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 | /** |
@@ 522-551 (lines=30) @@ | ||
519 | * @param string $tableName Table Name |
|
520 | * @return array |
|
521 | */ |
|
522 | protected function getIndexes($tableName) |
|
523 | { |
|
524 | $indexes = []; |
|
525 | $sql = "SELECT |
|
526 | i.relname AS index_name, |
|
527 | a.attname AS column_name |
|
528 | FROM |
|
529 | pg_class t, |
|
530 | pg_class i, |
|
531 | pg_index ix, |
|
532 | pg_attribute a |
|
533 | WHERE |
|
534 | t.oid = ix.indrelid |
|
535 | AND i.oid = ix.indexrelid |
|
536 | AND a.attrelid = t.oid |
|
537 | AND a.attnum = ANY(ix.indkey) |
|
538 | AND t.relkind = 'r' |
|
539 | AND t.relname = '$tableName' |
|
540 | ORDER BY |
|
541 | t.relname, |
|
542 | i.relname;"; |
|
543 | $rows = $this->fetchAll($sql); |
|
544 | foreach ($rows as $row) { |
|
545 | if (!isset($indexes[$row['index_name']])) { |
|
546 | $indexes[$row['index_name']] = ['columns' => []]; |
|
547 | } |
|
548 | $indexes[$row['index_name']]['columns'][] = strtolower($row['column_name']); |
|
549 | } |
|
550 | ||
551 | return $indexes; |
|
552 | } |
|
553 | ||
554 | /** |