| @@ 717-736 (lines=20) @@ | ||
| 714 | /** |
|
| 715 | * {@inheritdoc} |
|
| 716 | */ |
|
| 717 | public function hasForeignKey($tableName, $columns, $constraint = null) |
|
| 718 | { |
|
| 719 | if (is_string($columns)) { |
|
| 720 | $columns = [$columns]; // str to array |
|
| 721 | } |
|
| 722 | $foreignKeys = $this->getForeignKeys($tableName); |
|
| 723 | if ($constraint) { |
|
| 724 | if (isset($foreignKeys[$constraint])) { |
|
| 725 | return !empty($foreignKeys[$constraint]); |
|
| 726 | } |
|
| 727 | ||
| 728 | return false; |
|
| 729 | } else { |
|
| 730 | foreach ($foreignKeys as $key) { |
|
| 731 | if ($columns == $key['columns']) { |
|
| 732 | return true; |
|
| 733 | } |
|
| 734 | } |
|
| 735 | ||
| 736 | return false; |
|
| 737 | } |
|
| 738 | } |
|
| 739 | ||
| @@ 877-897 (lines=21) @@ | ||
| 874 | /** |
|
| 875 | * {@inheritdoc} |
|
| 876 | */ |
|
| 877 | public function hasForeignKey($tableName, $columns, $constraint = null) |
|
| 878 | { |
|
| 879 | if (is_string($columns)) { |
|
| 880 | $columns = [$columns]; // str to array |
|
| 881 | } |
|
| 882 | $foreignKeys = $this->getForeignKeys($tableName); |
|
| 883 | if ($constraint) { |
|
| 884 | if (isset($foreignKeys[$constraint])) { |
|
| 885 | return !empty($foreignKeys[$constraint]); |
|
| 886 | } |
|
| 887 | ||
| 888 | return false; |
|
| 889 | } else { |
|
| 890 | foreach ($foreignKeys as $key) { |
|
| 891 | $a = array_diff($columns, $key['columns']); |
|
| 892 | if (empty($a)) { |
|
| 893 | return true; |
|
| 894 | } |
|
| 895 | } |
|
| 896 | ||
| 897 | return false; |
|
| 898 | } |
|
| 899 | } |
|
| 900 | ||
| @@ 794-814 (lines=21) @@ | ||
| 791 | /** |
|
| 792 | * {@inheritdoc} |
|
| 793 | */ |
|
| 794 | public function hasForeignKey($tableName, $columns, $constraint = null) |
|
| 795 | { |
|
| 796 | if (is_string($columns)) { |
|
| 797 | $columns = [$columns]; // str to array |
|
| 798 | } |
|
| 799 | $foreignKeys = $this->getForeignKeys($tableName); |
|
| 800 | if ($constraint) { |
|
| 801 | if (isset($foreignKeys[$constraint])) { |
|
| 802 | return !empty($foreignKeys[$constraint]); |
|
| 803 | } |
|
| 804 | ||
| 805 | return false; |
|
| 806 | } else { |
|
| 807 | foreach ($foreignKeys as $key) { |
|
| 808 | $a = array_diff($columns, $key['columns']); |
|
| 809 | if (empty($a)) { |
|
| 810 | return true; |
|
| 811 | } |
|
| 812 | } |
|
| 813 | ||
| 814 | return false; |
|
| 815 | } |
|
| 816 | } |
|
| 817 | ||