From 749873e6c1587b71c5646650f0be9339a160149f Mon Sep 17 00:00:00 2001 From: zero Date: Thu, 23 Aug 2007 05:39:56 +0000 Subject: [PATCH] =?UTF-8?q?#113=20DB=20=ED=81=B4=EB=9E=98=EC=8A=A4?= =?UTF-8?q?=EC=97=90=20index=20=EC=9C=A0=EB=AC=B4=20=ED=8C=8C=EC=95=85?= =?UTF-8?q?=EA=B3=BC=20index=EC=B6=94=EA=B0=80=20method=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80.=20(mysql=EB=A7=8C=20=EB=8F=99=EC=9E=91)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://xe-core.googlecode.com/svn/sandbox@2387 201d5d3c-b55e-5fd7-737f-ddc643e51545 --- classes/db/DBCubrid.class.php | 13 +++++++++++++ classes/db/DBMysql.class.php | 24 ++++++++++++++++++++++++ classes/db/DBMysql_innodb.class.php | 22 ++++++++++++++++++++++ classes/db/DBSqlite2.class.php | 14 ++++++++++++++ classes/db/DBSqlite3_pdo.class.php | 14 ++++++++++++++ 5 files changed, 87 insertions(+) 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 을 받아서 테이블을 생성 **/