diff --git a/classes/db/DBCubrid.class.php b/classes/db/DBCubrid.class.php index a0d5897fb..9ed93e0c5 100644 --- a/classes/db/DBCubrid.class.php +++ b/classes/db/DBCubrid.class.php @@ -236,6 +236,19 @@ return $output; } + /** + * @brief 특정 테이블에 특정 인덱스 추가 + * $target_columns = array(col1, col2) + * $is_unique? unique : none + **/ + function addIndex($table_name, $index_name, $target_columns, $is_unique = false) { + } + + /** + * @brief 특정 테이블의 index 정보를 return + **/ + function isIndexExists($table_name, $index_name) { + } /** * @brief xml 을 받아서 테이블을 생성 diff --git a/classes/db/DBMysql.class.php b/classes/db/DBMysql.class.php index 5481e7dfc..fae3c63bd 100644 --- a/classes/db/DBMysql.class.php +++ b/classes/db/DBMysql.class.php @@ -244,6 +244,30 @@ return false; } + /** + * @brief 특정 테이블에 특정 인덱스 추가 + * $target_columns = array(col1, col2) + * $is_unique? unique : none + **/ + function addIndex($table_name, $index_name, $target_columns, $is_unique = false) { + if(!is_array($target_columns)) $target_columns = array($target_columns); + + $query = sprintf("alter table %s%s add %s index %s (%s);", $this->prefix, $table_name, $is_unique?'unique':'', $index_name, implode(',',$target_columns)); + $this->_query($query); + } + + /** + * @brief 특정 테이블의 index 정보를 return + **/ + function isIndexExists($table_name, $index_name) { + $query = sprintf("show indexes from %s%s where key_name = '%s' ", $this->prefix, $table_name, $index_name); + $result = $this->_query($query); + if($this->isError()) return; + $output = $this->_fetch($result); + if($output->Key_name == $index_name) return true; + return false; + } + /** * @brief xml 을 받아서 테이블을 생성 **/ diff --git a/classes/db/DBMysql_innodb.class.php b/classes/db/DBMysql_innodb.class.php index 31c14633d..2d0e4440f 100644 --- a/classes/db/DBMysql_innodb.class.php +++ b/classes/db/DBMysql_innodb.class.php @@ -253,7 +253,29 @@ return false; } + /** + * @brief 특정 테이블에 특정 인덱스 추가 + * $target_columns = array(col1, col2) + * $is_unique? unique : none + **/ + function addIndex($table_name, $index_name, $target_columns, $is_unique = false) { + if(!is_array($target_columns)) $target_columns = array($target_columns); + $query = sprintf("alter table %s%s add %s index %s (%s);", $this->prefix, $table_name, $is_unique?'unique':'', $index_name, implode(',',$target_columns)); + $this->_query($query); + } + + /** + * @brief 특정 테이블의 index 정보를 return + **/ + function isIndexExists($table_name, $index_name) { + $query = sprintf("show indexes from %s%s where key_name = '%s' ", $this->prefix, $table_name, $index_name); + $result = $this->_query($query); + if($this->isError()) return; + $output = $this->_fetch($result); + if($output->Key_name == $index_name) return true; + return false; + } /** * @brief xml 을 받아서 테이블을 생성 diff --git a/classes/db/DBSqlite2.class.php b/classes/db/DBSqlite2.class.php index dbb911d71..3a1a712c4 100644 --- a/classes/db/DBSqlite2.class.php +++ b/classes/db/DBSqlite2.class.php @@ -227,6 +227,20 @@ return false; } + /** + * @brief 특정 테이블에 특정 인덱스 추가 + * $target_columns = array(col1, col2) + * $is_unique? unique : none + **/ + function addIndex($table_name, $index_name, $target_columns, $is_unique = false) { + } + + /** + * @brief 특정 테이블의 index 정보를 return + **/ + function isIndexExists($table_name, $index_name) { + } + /** * @brief xml 을 받아서 테이블을 생성 **/ diff --git a/classes/db/DBSqlite3_pdo.class.php b/classes/db/DBSqlite3_pdo.class.php index 1706d6cca..478ceaaf9 100644 --- a/classes/db/DBSqlite3_pdo.class.php +++ b/classes/db/DBSqlite3_pdo.class.php @@ -250,6 +250,20 @@ return false; } + /** + * @brief 특정 테이블에 특정 인덱스 추가 + * $target_columns = array(col1, col2) + * $is_unique? unique : none + **/ + function addIndex($table_name, $index_name, $target_columns, $is_unique = false) { + } + + /** + * @brief 특정 테이블의 index 정보를 return + **/ + function isIndexExists($table_name, $index_name) { + } + /** * @brief xml 을 받아서 테이블을 생성 **/