diff --git a/classes/db/DBCubrid.class.php b/classes/db/DBCubrid.class.php index 8f089e1bb..ece9ad58b 100644 --- a/classes/db/DBCubrid.class.php +++ b/classes/db/DBCubrid.class.php @@ -506,7 +506,7 @@ $target_columns = array ($target_columns); } - $query = sprintf ("create %s index \"%s\" on \"%s%s\" (%s);", $is_unique?'unique':'', $this->prefix .$index_name, $this->prefix, $table_name, '"'.implode('","',$target_columns).'"'); + $query = sprintf ("create %s index \"%s\" on \"%s%s\" (%s);", $is_unique?'unique':'', $index_name, $this->prefix, $table_name, '"'.implode('","',$target_columns).'"'); $this->_query ($query); } @@ -520,7 +520,7 @@ */ function dropIndex ($table_name, $index_name, $is_unique = FALSE) { - $query = sprintf ("drop %s index \"%s\" on \"%s%s\"", $is_unique?'unique':'', $this->prefix .$index_name, $this->prefix, $table_name); + $query = sprintf ("drop %s index \"%s\" on \"%s%s\"", $is_unique?'unique':'', $index_name, $this->prefix, $table_name); $this->_query($query); } @@ -533,7 +533,7 @@ */ function isIndexExists ($table_name, $index_name) { - $query = sprintf ("select \"index_name\" from \"db_index\" where ". "\"class_name\" = '%s%s' and \"index_name\" = '%s' ", $this->prefix, $table_name, $this->prefix .$index_name); + $query = sprintf ("select \"index_name\" from \"db_index\" where ". "\"class_name\" = '%s%s' and (\"index_name\" = '%s' or \"index_name\" = '%s') ", $this->prefix, $table_name, $this->prefix .$index_name, $index_name); $result = $this->_query ($query); if ($this->isError ()) return FALSE; @@ -581,10 +581,18 @@ $output = $this->_fetch ($result); if (!$output) return FALSE; - $indexes_to_be_deleted = $output->data; + if(!is_array($output)) { + $indexes_to_be_deleted = array($output); + } + else { + $indexes_to_be_deleted = $output; + } + foreach($indexes_to_be_deleted as $index) { - $this->dropIndex($index->class_name, $index->unprefixed_index_name, $index->is_unique == 'YES' ? TRUE : FALSE); + $this->dropIndex(substr($index->class_name, strlen($this->prefix)) + , $this->prefix . $index->unprefixed_index_name + , $index->is_unique == 'YES' ? TRUE : FALSE); } return TRUE; @@ -718,14 +726,14 @@ if (count ($unique_list)) { foreach ($unique_list as $key => $val) { - $query = sprintf ("create unique index \"%s\" on \"%s\" ". "(%s);", $this->prefix .$key, $table_name, '"'.implode('","', $val).'"'); + $query = sprintf ("create unique index \"%s\" on \"%s\" ". "(%s);", $key, $table_name, '"'.implode('","', $val).'"'); $this->_query ($query); } } if (count ($index_list)) { foreach ($index_list as $key => $val) { - $query = sprintf ("create index \"%s\" on \"%s\" (%s);", $this->prefix .$key, $table_name, '"'.implode('","',$val).'"'); + $query = sprintf ("create index \"%s\" on \"%s\" (%s);", $key, $table_name, '"'.implode('","',$val).'"'); $this->_query ($query); } }