| @@ 813-833 (lines=21) @@ | ||
| 810 | /** | |
| 811 |      * {@inheritdoc} | |
| 812 | */ | |
| 813 | public function hasForeignKey($tableName, $columns, $constraint = null) | |
| 814 |     { | |
| 815 |         if (is_string($columns)) { | |
| 816 | $columns = [$columns]; // str to array | |
| 817 | } | |
| 818 | $foreignKeys = $this->getForeignKeys($tableName); | |
| 819 |         if ($constraint) { | |
| 820 |             if (isset($foreignKeys[$constraint])) { | |
| 821 | return !empty($foreignKeys[$constraint]); | |
| 822 | } | |
| 823 | ||
| 824 | return false; | |
| 825 |         } else { | |
| 826 |             foreach ($foreignKeys as $key) { | |
| 827 | $a = array_diff($columns, $key['columns']); | |
| 828 |                 if (empty($a)) { | |
| 829 | return true; | |
| 830 | } | |
| 831 | } | |
| 832 | ||
| 833 | return false; | |
| 834 | } | |
| 835 | } | |
| 836 | ||
| @@ 890-910 (lines=21) @@ | ||
| 887 | /** | |
| 888 |      * {@inheritdoc} | |
| 889 | */ | |
| 890 | public function hasForeignKey($tableName, $columns, $constraint = null) | |
| 891 |     { | |
| 892 |         if (is_string($columns)) { | |
| 893 | $columns = [$columns]; // str to array | |
| 894 | } | |
| 895 | $foreignKeys = $this->getForeignKeys($tableName); | |
| 896 |         if ($constraint) { | |
| 897 |             if (isset($foreignKeys[$constraint])) { | |
| 898 | return !empty($foreignKeys[$constraint]); | |
| 899 | } | |
| 900 | ||
| 901 | return false; | |
| 902 |         } else { | |
| 903 |             foreach ($foreignKeys as $key) { | |
| 904 | $a = array_diff($columns, $key['columns']); | |
| 905 |                 if (empty($a)) { | |
| 906 | return true; | |
| 907 | } | |
| 908 | } | |
| 909 | ||
| 910 | return false; | |
| 911 | } | |
| 912 | } | |
| 913 | ||
| @@ 754-773 (lines=20) @@ | ||
| 751 | /** | |
| 752 |      * {@inheritdoc} | |
| 753 | */ | |
| 754 | public function hasForeignKey($tableName, $columns, $constraint = null) | |
| 755 |     { | |
| 756 |         if (is_string($columns)) { | |
| 757 | $columns = [$columns]; // str to array | |
| 758 | } | |
| 759 | $foreignKeys = $this->getForeignKeys($tableName); | |
| 760 |         if ($constraint) { | |
| 761 |             if (isset($foreignKeys[$constraint])) { | |
| 762 | return !empty($foreignKeys[$constraint]); | |
| 763 | } | |
| 764 | ||
| 765 | return false; | |
| 766 |         } else { | |
| 767 |             foreach ($foreignKeys as $key) { | |
| 768 |                 if ($columns == $key['columns']) { | |
| 769 | return true; | |
| 770 | } | |
| 771 | } | |
| 772 | ||
| 773 | return false; | |
| 774 | } | |
| 775 | } | |
| 776 | ||