| @@ 607-631 (lines=25) @@ | ||
| 604 | * @param string $tableName Table Name | |
| 605 | * @return array | |
| 606 | */ | |
| 607 | protected function getForeignKeys($tableName) | |
| 608 |     { | |
| 609 | $foreignKeys = []; | |
| 610 | $rows = $this->fetchAll(sprintf( | |
| 611 | "SELECT | |
| 612 | CONSTRAINT_NAME, | |
| 613 | TABLE_NAME, | |
| 614 | COLUMN_NAME, | |
| 615 | REFERENCED_TABLE_NAME, | |
| 616 | REFERENCED_COLUMN_NAME | |
| 617 | FROM information_schema.KEY_COLUMN_USAGE | |
| 618 | WHERE REFERENCED_TABLE_SCHEMA = DATABASE() | |
| 619 | AND REFERENCED_TABLE_NAME IS NOT NULL | |
| 620 | AND TABLE_NAME = '%s' | |
| 621 | ORDER BY POSITION_IN_UNIQUE_CONSTRAINT", | |
| 622 | $tableName | |
| 623 | )); | |
| 624 |         foreach ($rows as $row) { | |
| 625 | $foreignKeys[$row['CONSTRAINT_NAME']]['table'] = $row['TABLE_NAME']; | |
| 626 | $foreignKeys[$row['CONSTRAINT_NAME']]['columns'][] = $row['COLUMN_NAME']; | |
| 627 | $foreignKeys[$row['CONSTRAINT_NAME']]['referenced_table'] = $row['REFERENCED_TABLE_NAME']; | |
| 628 | $foreignKeys[$row['CONSTRAINT_NAME']]['referenced_columns'][] = $row['REFERENCED_COLUMN_NAME']; | |
| 629 | } | |
| 630 | ||
| 631 | return $foreignKeys; | |
| 632 | } | |
| 633 | ||
| 634 | /** | |
| @@ 791-816 (lines=26) @@ | ||
| 788 | * @param string $tableName Table Name | |
| 789 | * @return array | |
| 790 | */ | |
| 791 | protected function getForeignKeys($tableName) | |
| 792 |     { | |
| 793 | $foreignKeys = []; | |
| 794 | $rows = $this->fetchAll(sprintf( | |
| 795 | "SELECT | |
| 796 | tc.constraint_name, | |
| 797 | tc.table_name, kcu.column_name, | |
| 798 | ccu.table_name AS referenced_table_name, | |
| 799 | ccu.column_name AS referenced_column_name | |
| 800 | FROM | |
| 801 | information_schema.table_constraints AS tc | |
| 802 | JOIN information_schema.key_column_usage AS kcu ON tc.constraint_name = kcu.constraint_name | |
| 803 | JOIN information_schema.constraint_column_usage AS ccu ON ccu.constraint_name = tc.constraint_name | |
| 804 | WHERE constraint_type = 'FOREIGN KEY' AND tc.table_name = '%s' | |
| 805 | ORDER BY kcu.ordinal_position", | |
| 806 | $tableName | |
| 807 | )); | |
| 808 |         foreach ($rows as $row) { | |
| 809 | $foreignKeys[$row['constraint_name']]['table'] = $row['table_name']; | |
| 810 | $foreignKeys[$row['constraint_name']]['columns'][] = $row['column_name']; | |
| 811 | $foreignKeys[$row['constraint_name']]['referenced_table'] = $row['referenced_table_name']; | |
| 812 | $foreignKeys[$row['constraint_name']]['referenced_columns'][] = $row['referenced_column_name']; | |
| 813 | } | |
| 814 | ||
| 815 | return $foreignKeys; | |
| 816 | } | |
| 817 | ||
| 818 | /** | |
| 819 |      * {@inheritdoc} | |