| @@ 594-613 (lines=20) @@ | ||
| 591 | /** |
|
| 592 | * {@inheritdoc} |
|
| 593 | */ |
|
| 594 | public function hasForeignKey($tableName, $columns, $constraint = null) |
|
| 595 | { |
|
| 596 | if (is_string($columns)) { |
|
| 597 | $columns = [$columns]; // str to array |
|
| 598 | } |
|
| 599 | $foreignKeys = $this->getForeignKeys($tableName); |
|
| 600 | if ($constraint) { |
|
| 601 | if (isset($foreignKeys[$constraint])) { |
|
| 602 | return !empty($foreignKeys[$constraint]); |
|
| 603 | } |
|
| 604 | ||
| 605 | return false; |
|
| 606 | } else { |
|
| 607 | foreach ($foreignKeys as $key) { |
|
| 608 | if ($columns == $key['columns']) { |
|
| 609 | return true; |
|
| 610 | } |
|
| 611 | } |
|
| 612 | ||
| 613 | return false; |
|
| 614 | } |
|
| 615 | } |
|
| 616 | ||
| @@ 602-622 (lines=21) @@ | ||
| 599 | /** |
|
| 600 | * {@inheritdoc} |
|
| 601 | */ |
|
| 602 | public function hasForeignKey($tableName, $columns, $constraint = null) |
|
| 603 | { |
|
| 604 | if (is_string($columns)) { |
|
| 605 | $columns = [$columns]; // str to array |
|
| 606 | } |
|
| 607 | $foreignKeys = $this->getForeignKeys($tableName); |
|
| 608 | if ($constraint) { |
|
| 609 | if (isset($foreignKeys[$constraint])) { |
|
| 610 | return !empty($foreignKeys[$constraint]); |
|
| 611 | } |
|
| 612 | ||
| 613 | return false; |
|
| 614 | } else { |
|
| 615 | foreach ($foreignKeys as $key) { |
|
| 616 | $a = array_diff($columns, $key['columns']); |
|
| 617 | if (empty($a)) { |
|
| 618 | return true; |
|
| 619 | } |
|
| 620 | } |
|
| 621 | ||
| 622 | return false; |
|
| 623 | } |
|
| 624 | } |
|
| 625 | ||
| @@ 732-752 (lines=21) @@ | ||
| 729 | /** |
|
| 730 | * {@inheritdoc} |
|
| 731 | */ |
|
| 732 | public function hasForeignKey($tableName, $columns, $constraint = null) |
|
| 733 | { |
|
| 734 | if (is_string($columns)) { |
|
| 735 | $columns = [$columns]; // str to array |
|
| 736 | } |
|
| 737 | $foreignKeys = $this->getForeignKeys($tableName); |
|
| 738 | if ($constraint) { |
|
| 739 | if (isset($foreignKeys[$constraint])) { |
|
| 740 | return !empty($foreignKeys[$constraint]); |
|
| 741 | } |
|
| 742 | ||
| 743 | return false; |
|
| 744 | } else { |
|
| 745 | foreach ($foreignKeys as $key) { |
|
| 746 | $a = array_diff($columns, $key['columns']); |
|
| 747 | if (empty($a)) { |
|
| 748 | return true; |
|
| 749 | } |
|
| 750 | } |
|
| 751 | ||
| 752 | return false; |
|
| 753 | } |
|
| 754 | } |
|
| 755 | ||