| @@ 587-606 (lines=20) @@ | ||
| 584 | /** |
|
| 585 | * {@inheritdoc} |
|
| 586 | */ |
|
| 587 | public function hasForeignKey($tableName, $columns, $constraint = null) |
|
| 588 | { |
|
| 589 | if (is_string($columns)) { |
|
| 590 | $columns = [$columns]; // str to array |
|
| 591 | } |
|
| 592 | $foreignKeys = $this->getForeignKeys($tableName); |
|
| 593 | if ($constraint) { |
|
| 594 | if (isset($foreignKeys[$constraint])) { |
|
| 595 | return !empty($foreignKeys[$constraint]); |
|
| 596 | } |
|
| 597 | ||
| 598 | return false; |
|
| 599 | } else { |
|
| 600 | foreach ($foreignKeys as $key) { |
|
| 601 | if ($columns == $key['columns']) { |
|
| 602 | return true; |
|
| 603 | } |
|
| 604 | } |
|
| 605 | ||
| 606 | return false; |
|
| 607 | } |
|
| 608 | } |
|
| 609 | ||
| @@ 733-753 (lines=21) @@ | ||
| 730 | /** |
|
| 731 | * {@inheritdoc} |
|
| 732 | */ |
|
| 733 | public function hasForeignKey($tableName, $columns, $constraint = null) |
|
| 734 | { |
|
| 735 | if (is_string($columns)) { |
|
| 736 | $columns = [$columns]; // str to array |
|
| 737 | } |
|
| 738 | $foreignKeys = $this->getForeignKeys($tableName); |
|
| 739 | if ($constraint) { |
|
| 740 | if (isset($foreignKeys[$constraint])) { |
|
| 741 | return !empty($foreignKeys[$constraint]); |
|
| 742 | } |
|
| 743 | ||
| 744 | return false; |
|
| 745 | } else { |
|
| 746 | foreach ($foreignKeys as $key) { |
|
| 747 | $a = array_diff($columns, $key['columns']); |
|
| 748 | if (empty($a)) { |
|
| 749 | return true; |
|
| 750 | } |
|
| 751 | } |
|
| 752 | ||
| 753 | return false; |
|
| 754 | } |
|
| 755 | } |
|
| 756 | ||
| @@ 668-688 (lines=21) @@ | ||
| 665 | /** |
|
| 666 | * {@inheritdoc} |
|
| 667 | */ |
|
| 668 | public function hasForeignKey($tableName, $columns, $constraint = null) |
|
| 669 | { |
|
| 670 | if (is_string($columns)) { |
|
| 671 | $columns = [$columns]; // str to array |
|
| 672 | } |
|
| 673 | $foreignKeys = $this->getForeignKeys($tableName); |
|
| 674 | if ($constraint) { |
|
| 675 | if (isset($foreignKeys[$constraint])) { |
|
| 676 | return !empty($foreignKeys[$constraint]); |
|
| 677 | } |
|
| 678 | ||
| 679 | return false; |
|
| 680 | } else { |
|
| 681 | foreach ($foreignKeys as $key) { |
|
| 682 | $a = array_diff($columns, $key['columns']); |
|
| 683 | if (empty($a)) { |
|
| 684 | return true; |
|
| 685 | } |
|
| 686 | } |
|
| 687 | ||
| 688 | return false; |
|
| 689 | } |
|
| 690 | } |
|
| 691 | ||