| @@ 746-771 (lines=26) @@ | ||
| 743 | * @param string $tableName Table Name | |
| 744 | * @return array | |
| 745 | */ | |
| 746 | protected function getForeignKeys($tableName) | |
| 747 |     { | |
| 748 | $foreignKeys = []; | |
| 749 | $rows = $this->fetchAll(sprintf( | |
| 750 | "SELECT | |
| 751 | CONSTRAINT_NAME, | |
| 752 | TABLE_NAME, | |
| 753 | COLUMN_NAME, | |
| 754 | REFERENCED_TABLE_NAME, | |
| 755 | REFERENCED_COLUMN_NAME | |
| 756 | FROM information_schema.KEY_COLUMN_USAGE | |
| 757 | WHERE REFERENCED_TABLE_SCHEMA = DATABASE() | |
| 758 | AND REFERENCED_TABLE_NAME IS NOT NULL | |
| 759 | AND TABLE_NAME = '%s' | |
| 760 | ORDER BY POSITION_IN_UNIQUE_CONSTRAINT", | |
| 761 | $tableName | |
| 762 | )); | |
| 763 |         foreach ($rows as $row) { | |
| 764 | $foreignKeys[$row['CONSTRAINT_NAME']]['table'] = $row['TABLE_NAME']; | |
| 765 | $foreignKeys[$row['CONSTRAINT_NAME']]['columns'][] = $row['COLUMN_NAME']; | |
| 766 | $foreignKeys[$row['CONSTRAINT_NAME']]['referenced_table'] = $row['REFERENCED_TABLE_NAME']; | |
| 767 | $foreignKeys[$row['CONSTRAINT_NAME']]['referenced_columns'][] = $row['REFERENCED_COLUMN_NAME']; | |
| 768 | } | |
| 769 | ||
| 770 | return $foreignKeys; | |
| 771 | } | |
| 772 | ||
| 773 | /** | |
| 774 |      * {@inheritdoc} | |
| @@ 907-932 (lines=26) @@ | ||
| 904 | * @param string $tableName Table Name | |
| 905 | * @return array | |
| 906 | */ | |
| 907 | protected function getForeignKeys($tableName) | |
| 908 |     { | |
| 909 | $foreignKeys = []; | |
| 910 | $rows = $this->fetchAll(sprintf( | |
| 911 | "SELECT | |
| 912 | tc.constraint_name, | |
| 913 | tc.table_name, kcu.column_name, | |
| 914 | ccu.table_name AS referenced_table_name, | |
| 915 | ccu.column_name AS referenced_column_name | |
| 916 | FROM | |
| 917 | information_schema.table_constraints AS tc | |
| 918 | JOIN information_schema.key_column_usage AS kcu ON tc.constraint_name = kcu.constraint_name | |
| 919 | JOIN information_schema.constraint_column_usage AS ccu ON ccu.constraint_name = tc.constraint_name | |
| 920 | WHERE constraint_type = 'FOREIGN KEY' AND tc.table_name = '%s' | |
| 921 | ORDER BY kcu.ordinal_position", | |
| 922 | $tableName | |
| 923 | )); | |
| 924 |         foreach ($rows as $row) { | |
| 925 | $foreignKeys[$row['constraint_name']]['table'] = $row['table_name']; | |
| 926 | $foreignKeys[$row['constraint_name']]['columns'][] = $row['column_name']; | |
| 927 | $foreignKeys[$row['constraint_name']]['referenced_table'] = $row['referenced_table_name']; | |
| 928 | $foreignKeys[$row['constraint_name']]['referenced_columns'][] = $row['referenced_column_name']; | |
| 929 | } | |
| 930 | ||
| 931 | return $foreignKeys; | |
| 932 | } | |
| 933 | ||
| 934 | /** | |
| 935 |      * {@inheritdoc} | |