| @@ 685-702 (lines=18) @@ | ||
| 682 | /** |
|
| 683 | * {@inheritdoc} |
|
| 684 | */ |
|
| 685 | public function hasPrimaryKey($tableName, $columns, $constraint = null) |
|
| 686 | { |
|
| 687 | $primaryKey = $this->getPrimaryKey($tableName); |
|
| 688 | ||
| 689 | if (empty($primaryKey['constraint'])) { |
|
| 690 | return false; |
|
| 691 | } |
|
| 692 | ||
| 693 | if ($constraint) { |
|
| 694 | return ($primaryKey['constraint'] === $constraint); |
|
| 695 | } else { |
|
| 696 | if (is_string($columns)) { |
|
| 697 | $columns = [$columns]; // str to array |
|
| 698 | } |
|
| 699 | $missingColumns = array_diff($columns, $primaryKey['columns']); |
|
| 700 | return empty($missingColumns); |
|
| 701 | } |
|
| 702 | } |
|
| 703 | ||
| 704 | /** |
|
| 705 | * Get the primary key from a particular table. |
|
| @@ 756-773 (lines=18) @@ | ||
| 753 | /** |
|
| 754 | * {@inheritdoc} |
|
| 755 | */ |
|
| 756 | public function hasPrimaryKey($tableName, $columns, $constraint = null) |
|
| 757 | { |
|
| 758 | $primaryKey = $this->getPrimaryKey($tableName); |
|
| 759 | ||
| 760 | if (empty($primaryKey)) { |
|
| 761 | return false; |
|
| 762 | } |
|
| 763 | ||
| 764 | if ($constraint) { |
|
| 765 | return ($primaryKey['constraint'] === $constraint); |
|
| 766 | } else { |
|
| 767 | if (is_string($columns)) { |
|
| 768 | $columns = [$columns]; // str to array |
|
| 769 | } |
|
| 770 | $missingColumns = array_diff($columns, $primaryKey['columns']); |
|
| 771 | return empty($missingColumns); |
|
| 772 | } |
|
| 773 | } |
|
| 774 | ||
| 775 | /** |
|
| 776 | * Get the primary key from a particular table. |
|
| @@ 836-853 (lines=18) @@ | ||
| 833 | /** |
|
| 834 | * {@inheritdoc} |
|
| 835 | */ |
|
| 836 | public function hasPrimaryKey($tableName, $columns, $constraint = null) |
|
| 837 | { |
|
| 838 | $primaryKey = $this->getPrimaryKey($tableName); |
|
| 839 | ||
| 840 | if (empty($primaryKey)) { |
|
| 841 | return false; |
|
| 842 | } |
|
| 843 | ||
| 844 | if ($constraint) { |
|
| 845 | return ($primaryKey['constraint'] === $constraint); |
|
| 846 | } else { |
|
| 847 | if (is_string($columns)) { |
|
| 848 | $columns = [$columns]; // str to array |
|
| 849 | } |
|
| 850 | $missingColumns = array_diff($columns, $primaryKey['columns']); |
|
| 851 | return empty($missingColumns); |
|
| 852 | } |
|
| 853 | } |
|
| 854 | ||
| 855 | /** |
|
| 856 | * Get the primary key from a particular table. |
|