| @@ 869-889 (lines=21) @@ | ||
| 866 | /** |
|
| 867 | * {@inheritdoc} |
|
| 868 | */ |
|
| 869 | public function hasForeignKey($tableName, $columns, $constraint = null) |
|
| 870 | { |
|
| 871 | if (is_string($columns)) { |
|
| 872 | $columns = [$columns]; // str to array |
|
| 873 | } |
|
| 874 | $foreignKeys = $this->getForeignKeys($tableName); |
|
| 875 | if ($constraint) { |
|
| 876 | if (isset($foreignKeys[$constraint])) { |
|
| 877 | return !empty($foreignKeys[$constraint]); |
|
| 878 | } |
|
| 879 | ||
| 880 | return false; |
|
| 881 | } else { |
|
| 882 | foreach ($foreignKeys as $key) { |
|
| 883 | $a = array_diff($columns, $key['columns']); |
|
| 884 | if (empty($a)) { |
|
| 885 | return true; |
|
| 886 | } |
|
| 887 | } |
|
| 888 | ||
| 889 | return false; |
|
| 890 | } |
|
| 891 | } |
|
| 892 | ||
| @@ 783-803 (lines=21) @@ | ||
| 780 | /** |
|
| 781 | * {@inheritdoc} |
|
| 782 | */ |
|
| 783 | public function hasForeignKey($tableName, $columns, $constraint = null) |
|
| 784 | { |
|
| 785 | if (is_string($columns)) { |
|
| 786 | $columns = [$columns]; // str to array |
|
| 787 | } |
|
| 788 | $foreignKeys = $this->getForeignKeys($tableName); |
|
| 789 | if ($constraint) { |
|
| 790 | if (isset($foreignKeys[$constraint])) { |
|
| 791 | return !empty($foreignKeys[$constraint]); |
|
| 792 | } |
|
| 793 | ||
| 794 | return false; |
|
| 795 | } else { |
|
| 796 | foreach ($foreignKeys as $key) { |
|
| 797 | $a = array_diff($columns, $key['columns']); |
|
| 798 | if (empty($a)) { |
|
| 799 | return true; |
|
| 800 | } |
|
| 801 | } |
|
| 802 | ||
| 803 | return false; |
|
| 804 | } |
|
| 805 | } |
|
| 806 | ||
| @@ 709-728 (lines=20) @@ | ||
| 706 | /** |
|
| 707 | * {@inheritdoc} |
|
| 708 | */ |
|
| 709 | public function hasForeignKey($tableName, $columns, $constraint = null) |
|
| 710 | { |
|
| 711 | if (is_string($columns)) { |
|
| 712 | $columns = [$columns]; // str to array |
|
| 713 | } |
|
| 714 | $foreignKeys = $this->getForeignKeys($tableName); |
|
| 715 | if ($constraint) { |
|
| 716 | if (isset($foreignKeys[$constraint])) { |
|
| 717 | return !empty($foreignKeys[$constraint]); |
|
| 718 | } |
|
| 719 | ||
| 720 | return false; |
|
| 721 | } else { |
|
| 722 | foreach ($foreignKeys as $key) { |
|
| 723 | if ($columns == $key['columns']) { |
|
| 724 | return true; |
|
| 725 | } |
|
| 726 | } |
|
| 727 | ||
| 728 | return false; |
|
| 729 | } |
|
| 730 | } |
|
| 731 | ||