| @@ 489-518 (lines=30) @@ | ||
| 486 | * @param string $tableName Table Name |
|
| 487 | * @return array |
|
| 488 | */ |
|
| 489 | protected function getIndexes($tableName) |
|
| 490 | { |
|
| 491 | $indexes = []; |
|
| 492 | $sql = "SELECT |
|
| 493 | i.relname AS index_name, |
|
| 494 | a.attname AS column_name |
|
| 495 | FROM |
|
| 496 | pg_class t, |
|
| 497 | pg_class i, |
|
| 498 | pg_index ix, |
|
| 499 | pg_attribute a |
|
| 500 | WHERE |
|
| 501 | t.oid = ix.indrelid |
|
| 502 | AND i.oid = ix.indexrelid |
|
| 503 | AND a.attrelid = t.oid |
|
| 504 | AND a.attnum = ANY(ix.indkey) |
|
| 505 | AND t.relkind = 'r' |
|
| 506 | AND t.relname = '$tableName' |
|
| 507 | ORDER BY |
|
| 508 | t.relname, |
|
| 509 | i.relname;"; |
|
| 510 | $rows = $this->fetchAll($sql); |
|
| 511 | foreach ($rows as $row) { |
|
| 512 | if (!isset($indexes[$row['index_name']])) { |
|
| 513 | $indexes[$row['index_name']] = ['columns' => []]; |
|
| 514 | } |
|
| 515 | $indexes[$row['index_name']]['columns'][] = strtolower($row['column_name']); |
|
| 516 | } |
|
| 517 | ||
| 518 | return $indexes; |
|
| 519 | } |
|
| 520 | ||
| 521 | /** |
|
| @@ 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 | /** |
|
| @@ 487-501 (lines=15) @@ | ||
| 484 | * @param string $tableName Table Name |
|
| 485 | * @return array |
|
| 486 | */ |
|
| 487 | public function getIndexes($tableName) |
|
| 488 | { |
|
| 489 | $indexes = []; |
|
| 490 | $sql = "SELECT index_owner as owner,index_name,column_name FROM ALL_IND_COLUMNS |
|
| 491 | WHERE TABLE_NAME = '$tableName'"; |
|
| 492 | ||
| 493 | $rows = $this->fetchAll($sql); |
|
| 494 | foreach ($rows as $row) { |
|
| 495 | if (!isset($indexes[$row['INDEX_NAME']])) { |
|
| 496 | $indexes[$row['INDEX_NAME']] = ['columns' => []]; |
|
| 497 | } |
|
| 498 | $indexes[$row['INDEX_NAME']]['columns'][] = strtoupper($row['COLUMN_NAME']); |
|
| 499 | } |
|
| 500 | ||
| 501 | return $indexes; |
|
| 502 | } |
|
| 503 | ||
| 504 | /** |
|