From c3e85b349cdbf88359b8f1cf9e2bddd23870c4af Mon Sep 17 00:00:00 2001 From: zero Date: Thu, 23 Aug 2007 04:13:34 +0000 Subject: [PATCH] =?UTF-8?q?Sqlite2/3=EC=97=90=EB=8F=84=20list=5Forder/upda?= =?UTF-8?q?te=5Forder=EC=97=90=20=EB=8C=80=ED=95=B4=20=EC=9D=B8=EB=8D=B1?= =?UTF-8?q?=EC=8A=A4=EB=A5=BC=20=ED=99=9C=EC=9A=A9=ED=95=98=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20db=20class=20=EC=88=98=EC=A0=95?= 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@2384 201d5d3c-b55e-5fd7-737f-ddc643e51545 --- classes/db/DBSqlite2.class.php | 20 ++++++++++++++++++++ classes/db/DBSqlite3_pdo.class.php | 20 ++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/classes/db/DBSqlite2.class.php b/classes/db/DBSqlite2.class.php index d0e7dda18..dbb911d71 100644 --- a/classes/db/DBSqlite2.class.php +++ b/classes/db/DBSqlite2.class.php @@ -495,6 +495,16 @@ if($output->list_count) return $this->_getNavigationData($table_list, $columns, $condition, $output); + // list_order, update_order 로 정렬시에 인덱스 사용을 위해 condition에 쿼리 추가 + if($output->order) { + foreach($output->order as $key => $val) { + $col = $val[0]; + if(!in_array($col, array('list_order','update_order'))) continue; + if($condition) $condition .= sprintf(' and %s < 0 ', $col); + else $condition = sprintf(' where %s < 0 ', $col); + } + } + $query = sprintf("select %s from %s %s", $columns, implode(',',$table_list), $condition); if(count($output->groups)) $query .= sprintf(' group by %s', implode(',',$output->groups)); @@ -544,6 +554,16 @@ if($page > $total_page) $page = $total_page; $start_count = ($page-1)*$list_count; + // list_order, update_order 로 정렬시에 인덱스 사용을 위해 condition에 쿼리 추가 + if($output->order) { + foreach($output->order as $key => $val) { + $col = $val[0]; + if(!in_array($col, array('list_order','update_order'))) continue; + if($condition) $condition .= sprintf(' and %s < 0 ', $col); + else $condition = sprintf(' where %s < 0 ', $col); + } + } + $query = sprintf("select %s from %s %s", $columns, implode(',',$table_list), $condition); if(count($output->groups)) $query .= sprintf(' group by %s', implode(',',$output->groups)); diff --git a/classes/db/DBSqlite3_pdo.class.php b/classes/db/DBSqlite3_pdo.class.php index 9a1d37a0f..1706d6cca 100644 --- a/classes/db/DBSqlite3_pdo.class.php +++ b/classes/db/DBSqlite3_pdo.class.php @@ -535,6 +535,16 @@ if($output->list_count) return $this->_getNavigationData($table_list, $columns, $condition, $output); + // list_order, update_order 로 정렬시에 인덱스 사용을 위해 condition에 쿼리 추가 + if($output->order) { + foreach($output->order as $key => $val) { + $col = $val[0]; + if(!in_array($col, array('list_order','update_order'))) continue; + if($condition) $condition .= sprintf(' and %s < 0 ', $col); + else $condition = sprintf(' where %s < 0 ', $col); + } + } + $query = sprintf("select %s from %s %s", $columns, implode(',',$table_list), $condition); if(count($output->groups)) $query .= sprintf(' group by %s', implode(',',$output->groups)); @@ -584,6 +594,16 @@ if($page > $total_page) $page = $total_page; $start_count = ($page-1)*$list_count; + // list_order, update_order 로 정렬시에 인덱스 사용을 위해 condition에 쿼리 추가 + if($output->order) { + foreach($output->order as $key => $val) { + $col = $val[0]; + if(!in_array($col, array('list_order','update_order'))) continue; + if($condition) $condition .= sprintf(' and %s < 0 ', $col); + else $condition = sprintf(' where %s < 0 ', $col); + } + } + $query = sprintf("select %s from %s %s", $columns, implode(',',$table_list), $condition); if(count($output->groups)) $query .= sprintf(' group by %s', implode(',',$output->groups));