| @@ 738-757 (lines=20) @@ | ||
| 735 | /** |
|
| 736 | * {@inheritdoc} |
|
| 737 | */ |
|
| 738 | public function hasForeignKey($tableName, $columns, $constraint = null) |
|
| 739 | { |
|
| 740 | if (is_string($columns)) { |
|
| 741 | $columns = [$columns]; // str to array |
|
| 742 | } |
|
| 743 | $foreignKeys = $this->getForeignKeys($tableName); |
|
| 744 | if ($constraint) { |
|
| 745 | if (isset($foreignKeys[$constraint])) { |
|
| 746 | return !empty($foreignKeys[$constraint]); |
|
| 747 | } |
|
| 748 | ||
| 749 | return false; |
|
| 750 | } else { |
|
| 751 | foreach ($foreignKeys as $key) { |
|
| 752 | if ($columns == $key['columns']) { |
|
| 753 | return true; |
|
| 754 | } |
|
| 755 | } |
|
| 756 | ||
| 757 | return false; |
|
| 758 | } |
|
| 759 | } |
|
| 760 | ||
| @@ 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 | ||