| @@ 867-890 (lines=24) @@ | ||
| 864 | * |
|
| 865 | * @return array |
|
| 866 | */ |
|
| 867 | public function getPrimaryKey($tableName) |
|
| 868 | { |
|
| 869 | $rows = $this->fetchAll(sprintf( |
|
| 870 | "SELECT |
|
| 871 | tc.constraint_name, |
|
| 872 | kcu.column_name |
|
| 873 | FROM information_schema.table_constraints AS tc |
|
| 874 | JOIN information_schema.key_column_usage AS kcu |
|
| 875 | ON tc.constraint_name = kcu.constraint_name |
|
| 876 | WHERE constraint_type = 'PRIMARY KEY' |
|
| 877 | AND tc.table_name = '%s' |
|
| 878 | ORDER BY kcu.ordinal_position", |
|
| 879 | $tableName |
|
| 880 | )); |
|
| 881 | ||
| 882 | $primaryKey = [ |
|
| 883 | 'columns' => [], |
|
| 884 | ]; |
|
| 885 | foreach ($rows as $row) { |
|
| 886 | $primaryKey['constraint'] = $row['constraint_name']; |
|
| 887 | $primaryKey['columns'][] = $row['column_name']; |
|
| 888 | } |
|
| 889 | ||
| 890 | return $primaryKey; |
|
| 891 | } |
|
| 892 | ||
| 893 | /** |
|
| @@ 698-720 (lines=23) @@ | ||
| 695 | * |
|
| 696 | * @return array |
|
| 697 | */ |
|
| 698 | public function getPrimaryKey($tableName) |
|
| 699 | { |
|
| 700 | $rows = $this->fetchAll(sprintf( |
|
| 701 | "SELECT |
|
| 702 | k.constraint_name, |
|
| 703 | k.column_name |
|
| 704 | FROM information_schema.table_constraints t |
|
| 705 | JOIN information_schema.key_column_usage k |
|
| 706 | USING(constraint_name,table_name) |
|
| 707 | WHERE t.constraint_type='PRIMARY KEY' |
|
| 708 | AND t.table_name='%s'", |
|
| 709 | $tableName |
|
| 710 | )); |
|
| 711 | ||
| 712 | $primaryKey = [ |
|
| 713 | 'columns' => [], |
|
| 714 | ]; |
|
| 715 | foreach ($rows as $row) { |
|
| 716 | $primaryKey['constraint'] = $row['constraint_name']; |
|
| 717 | $primaryKey['columns'][] = $row['column_name']; |
|
| 718 | } |
|
| 719 | ||
| 720 | return $primaryKey; |
|
| 721 | } |
|
| 722 | ||
| 723 | /** |
|