| @@ 604-623 (lines=20) @@ | ||
| 601 | /** |
|
| 602 | * {@inheritdoc} |
|
| 603 | */ |
|
| 604 | public function hasForeignKey($tableName, $columns, $constraint = null) |
|
| 605 | { |
|
| 606 | if (is_string($columns)) { |
|
| 607 | $columns = [$columns]; // str to array |
|
| 608 | } |
|
| 609 | $foreignKeys = $this->getForeignKeys($tableName); |
|
| 610 | if ($constraint) { |
|
| 611 | if (isset($foreignKeys[$constraint])) { |
|
| 612 | return !empty($foreignKeys[$constraint]); |
|
| 613 | } |
|
| 614 | ||
| 615 | return false; |
|
| 616 | } else { |
|
| 617 | foreach ($foreignKeys as $key) { |
|
| 618 | if ($columns == $key['columns']) { |
|
| 619 | return true; |
|
| 620 | } |
|
| 621 | } |
|
| 622 | ||
| 623 | return false; |
|
| 624 | } |
|
| 625 | } |
|
| 626 | ||
| @@ 742-762 (lines=21) @@ | ||
| 739 | /** |
|
| 740 | * {@inheritdoc} |
|
| 741 | */ |
|
| 742 | public function hasForeignKey($tableName, $columns, $constraint = null) |
|
| 743 | { |
|
| 744 | if (is_string($columns)) { |
|
| 745 | $columns = [$columns]; // str to array |
|
| 746 | } |
|
| 747 | $foreignKeys = $this->getForeignKeys($tableName); |
|
| 748 | if ($constraint) { |
|
| 749 | if (isset($foreignKeys[$constraint])) { |
|
| 750 | return !empty($foreignKeys[$constraint]); |
|
| 751 | } |
|
| 752 | ||
| 753 | return false; |
|
| 754 | } else { |
|
| 755 | foreach ($foreignKeys as $key) { |
|
| 756 | $a = array_diff($columns, $key['columns']); |
|
| 757 | if (empty($a)) { |
|
| 758 | return true; |
|
| 759 | } |
|
| 760 | } |
|
| 761 | ||
| 762 | return false; |
|
| 763 | } |
|
| 764 | } |
|
| 765 | ||
| @@ 631-651 (lines=21) @@ | ||
| 628 | /** |
|
| 629 | * {@inheritdoc} |
|
| 630 | */ |
|
| 631 | public function hasForeignKey($tableName, $columns, $constraint = null) |
|
| 632 | { |
|
| 633 | if (is_string($columns)) { |
|
| 634 | $columns = [$columns]; // str to array |
|
| 635 | } |
|
| 636 | $foreignKeys = $this->getForeignKeys($tableName); |
|
| 637 | if ($constraint) { |
|
| 638 | if (isset($foreignKeys[$constraint])) { |
|
| 639 | return !empty($foreignKeys[$constraint]); |
|
| 640 | } |
|
| 641 | ||
| 642 | return false; |
|
| 643 | } else { |
|
| 644 | foreach ($foreignKeys as $key) { |
|
| 645 | $a = array_diff($columns, $key['columns']); |
|
| 646 | if (empty($a)) { |
|
| 647 | return true; |
|
| 648 | } |
|
| 649 | } |
|
| 650 | ||
| 651 | return false; |
|
| 652 | } |
|
| 653 | } |
|
| 654 | ||