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