Changeset 10042

Show
Ignore:
Timestamp:
11/29/08 14:34:25 (1 month ago)
Author:
afz
Message:

Update for MDB2_Schema

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/jaws/html/libraries/pear/MDB2/Schema.php

    r10007 r10042  
    18701870        if (!empty($changes['change']) && is_array($changes['change'])) { 
    18711871            foreach ($changes['change'] as $index_name => $index) { 
     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 
    18721890                if (!empty($index['primary']) || !empty($index['unique'])) { 
    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                     } 
    18851891                    $result = $this->db->manager->createConstraint($table_name, $index_name, $index); 
    18861892                } else { 
    1887                     $this->db->expectError(MDB2_ERROR_NOT_FOUND); 
    1888                     $result = $this->db->manager->dropIndex($table_name, $index_name); 
    1889                     $this->db->popExpect(); 
    1890                     if (PEAR::isError($result) && !MDB2::isError($result, MDB2_ERROR_NOT_FOUND)) { 
    1891                         return $result; 
    1892                     } 
    18931893                    $result = $this->db->manager->createIndex($table_name, $index_name, $index); 
    18941894                }