| | 1872 | /** |
|---|
| | 1873 | * Drop existing index/constraint first. |
|---|
| | 1874 | * Since $changes doesn't tell us whether it's an index or a constraint before the change, |
|---|
| | 1875 | * we have to find out and call the appropriate method. |
|---|
| | 1876 | */ |
|---|
| | 1877 | if (in_array($index_name, $this->db->manager->listTableIndexes($table_name))) { |
|---|
| | 1878 | $result = $this->db->manager->dropIndex($table_name, $index_name); |
|---|
| | 1879 | if (!empty($result) && PEAR::isError($result)) { |
|---|
| | 1880 | return $result; |
|---|
| | 1881 | } |
|---|
| | 1882 | } |
|---|
| | 1883 | if (in_array($index_name, $this->db->manager->listTableConstraints($table_name))) { |
|---|
| | 1884 | $result = $this->db->manager->dropConstraint($table_name, $index_name); |
|---|
| | 1885 | if (!empty($result) && PEAR::isError($result)) { |
|---|
| | 1886 | return $result; |
|---|
| | 1887 | } |
|---|
| | 1888 | } |
|---|
| | 1889 | |
|---|
| 1873 | | $this->db->expectError(MDB2_ERROR_NOT_FOUND); |
|---|
| 1874 | | $result = $this->db->manager->dropIndex($table_name, $index_name); |
|---|
| 1875 | | $this->db->popExpect(); |
|---|
| 1876 | | if (PEAR::isError($result) && !MDB2::isError($result, MDB2_ERROR_NOT_FOUND)) { |
|---|
| 1877 | | return $result; |
|---|
| 1878 | | } |
|---|
| 1879 | | $this->db->expectError(MDB2_ERROR_NOT_FOUND); |
|---|
| 1880 | | $result = $this->db->manager->dropConstraint($table_name, $index_name, !empty($index['primary'])); |
|---|
| 1881 | | $this->db->popExpect(); |
|---|
| 1882 | | if (PEAR::isError($result) && !MDB2::isError($result, MDB2_ERROR_NOT_FOUND)) { |
|---|
| 1883 | | return $result; |
|---|
| 1884 | | } |
|---|