페이징을 할 경우 DB class에서 navigation을 처리하도록 변경

git-svn-id: http://xe-core.googlecode.com/svn/sandbox@3154 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
zero 2007-12-04 08:26:15 +00:00
parent 6a322a17ce
commit 539c32082e
6 changed files with 133 additions and 49 deletions

View file

@ -246,6 +246,7 @@
if( (is_a($output, 'Object')||is_subclass_of($output,'Object'))&&!$output->toBool()) return $output;
// action값에 따라서 쿼리 생성으로 돌입
switch($output->action) {
case 'insert' :
@ -395,5 +396,24 @@
break;
}
}
/**
* @brief condition key를 return
**/
function getConditionList($output) {
$conditions = array();
if(count($output->conditions)) {
foreach($output->conditions as $key => $val) {
if($val['condition']) {
foreach($val['condition'] as $k => $v) {
$conditions[] = $v['column'];
}
}
}
}
return $conditions;
}
}
?>

View file

@ -556,17 +556,45 @@
$condition = $this->getCondition($output);
if($output->list_count) return $this->_getNavigationData($table_list, $columns, $condition, $output);
if($output->list_count && $output->page) return $this->_getNavigationData($table_list, $columns, $condition, $output);
$query = sprintf("select %s from %s %s", $columns, implode(',',$table_list), $condition);
if(count($output->groups)) $query .= sprintf(' group by %s', implode(',',$output->groups));
if($output->order) {
foreach($output->order as $key => $val) {
// list_count를 사용할 경우 적용
if($output->list_count['value']) {
$start_count = 0;
$list_count = $output->list_count['value'];
if ($output->order) {
foreach($output->order as $key => $val) {
$index_list[] = sprintf('%s %s', $val[0], $val[1]);
}
if(count($index_list)) $query .= ' order by '.implode(',',$index_list);
$query = sprintf('%s for orderby_num() between %d and %d', $query, $start_count, $list_count);
}
if(count($index_list)) $query .= ' order by '.implode(',',$index_list);
else {
if (count($output->groups))
$query = sprintf('%s having groupby_num() between %d and %d', $query, $start_count, $list_count);
else {
if ($condition)
$query = sprintf('%s and inst_num() between %d and %d', $query, $start_count, $list_count);
else
$query = sprintf('%s where inst_num() between %d and %d', $query, $start_count, $list_count);
}
}
} else {
if($output->order) {
foreach($output->order as $key => $val) {
$index_list[] = sprintf('%s %s', $val[0], $val[1]);
}
if(count($index_list)) $query .= ' order by '.implode(',',$index_list);
}
}
$result = $this->_query($query);

View file

@ -499,15 +499,18 @@
$condition = $this->getCondition($output);
if($output->list_count) return $this->_getNavigationData($table_list, $columns, $condition, $output);
if($output->list_count && $output->page) 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 < 2100000000 ', $col);
else $condition = sprintf(' where %s < 2100000000 ', $col);
$conditions = $this->getConditionList($output);
if(!in_array('list_order', $conditions) && !in_array('update_order', $conditions)) {
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 < 2100000000 ', $col);
else $condition = sprintf(' where %s < 2100000000 ', $col);
}
}
}
@ -522,6 +525,9 @@
if(count($index_list)) $query .= ' order by '.implode(',',$index_list);
}
// list_count를 사용할 경우 적용
if($output->list_count['value']) $query = sprintf('%s limit %d', $query, $output->list_count['value']);
$result = $this->_query($query);
if($this->isError()) return;
$data = $this->_fetch($result);
@ -562,11 +568,14 @@
// 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 < 2100000000 ', $col);
else $condition = sprintf(' where %s < 2100000000 ', $col);
$conditions = $this->getConditionList($output);
if(!in_array('list_order', $conditions) && !in_array('update_order', $conditions)) {
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 < 2100000000 ', $col);
else $condition = sprintf(' where %s < 2100000000 ', $col);
}
}
}

View file

@ -508,15 +508,18 @@
$condition = $this->getCondition($output);
if($output->list_count) return $this->_getNavigationData($table_list, $columns, $condition, $output);
if($output->list_count && $output->page) 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 < 2100000000 ', $col);
else $condition = sprintf(' where %s < 2100000000 ', $col);
$conditions = $this->getConditionList($output);
if(!in_array('list_order', $conditions) && !in_array('update_order', $conditions)) {
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 < 2100000000 ', $col);
else $condition = sprintf(' where %s < 2100000000 ', $col);
}
}
}
@ -531,6 +534,9 @@
if(count($index_list)) $query .= ' order by '.implode(',',$index_list);
}
// list_count를 사용할 경우 적용
if($output->list_count['value']) $query = sprintf('%s limit %d', $query, $output->list_count['value']);
$result = $this->_query($query);
if($this->isError()) return;
$data = $this->_fetch($result);
@ -571,11 +577,14 @@
// 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 < 2100000000 ', $col);
else $condition = sprintf(' where %s < 2100000000 ', $col);
$conditions = $this->getConditionList($output);
if(!in_array('list_order', $conditions) && !in_array('update_order', $conditions)) {
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 < 2100000000 ', $col);
else $condition = sprintf(' where %s < 2100000000 ', $col);
}
}
}
@ -590,7 +599,7 @@
}
$query = sprintf('%s limit %d, %d', $query, $start_count, $list_count);
$result = $this->_query($query);
if($this->isError()) {
$buff = new Object();

View file

@ -520,15 +520,18 @@
$condition = $this->getCondition($output);
if($output->list_count) return $this->_getNavigationData($table_list, $columns, $condition, $output);
if($output->list_count && $output->page) 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 < 2100000000 ', $col);
else $condition = sprintf(' where %s < 2100000000 ', $col);
$conditions = $this->getConditionList($output);
if(!in_array('list_order', $conditions) && !in_array('update_order', $conditions)) {
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 < 2100000000 ', $col);
else $condition = sprintf(' where %s < 2100000000 ', $col);
}
}
}
@ -543,6 +546,9 @@
if(count($index_list)) $query .= ' order by '.implode(',',$index_list);
}
// list_count를 사용할 경우 적용
if($output->list_count['value']) $query = sprintf('%s limit %d', $query, $output->list_count['value']);
$result = $this->_query($query);
if($this->isError()) return;
$data = $this->_fetch($result);
@ -583,11 +589,14 @@
// 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 < 2100000000 ', $col);
else $condition = sprintf(' where %s < 2100000000 ', $col);
$conditions = $this->getConditionList($output);
if(!in_array('list_order', $conditions) && !in_array('update_order', $conditions)) {
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 < 2100000000 ', $col);
else $condition = sprintf(' where %s < 2100000000 ', $col);
}
}
}

View file

@ -561,15 +561,18 @@
$condition = $this->getCondition($output);
if($output->list_count) return $this->_getNavigationData($table_list, $columns, $condition, $output);
if($output->list_count && $output->page) 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 < 2100000000 ', $col);
else $condition = sprintf(' where %s < 2100000000 ', $col);
$conditions = $this->getConditionList($output);
if(!in_array('list_order', $conditions) && !in_array('update_order', $conditions)) {
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 < 2100000000 ', $col);
else $condition = sprintf(' where %s < 2100000000 ', $col);
}
}
}
@ -584,6 +587,9 @@
if(count($index_list)) $query .= ' order by '.implode(',',$index_list);
}
// list_count를 사용할 경우 적용
if($output->list_count['value']) $query = sprintf('%s limit %d', $query, $output->list_count['value']);
$this->_prepare($query);
$data = $this->_execute();
if($this->isError()) return;
@ -624,11 +630,14 @@
// 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 < 2100000000 ', $col);
else $condition = sprintf(' where %s < 2100000000 ', $col);
$conditions = $this->getConditionList($output);
if(!in_array('list_order', $conditions) && !in_array('update_order', $conditions)) {
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 < 2100000000 ', $col);
else $condition = sprintf(' where %s < 2100000000 ', $col);
}
}
}