mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-10 12:32:14 +09:00
페이징을 할 경우 DB class에서 navigation을 처리하도록 변경
git-svn-id: http://xe-core.googlecode.com/svn/sandbox@3154 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
6a322a17ce
commit
539c32082e
6 changed files with 133 additions and 49 deletions
|
|
@ -246,6 +246,7 @@
|
||||||
|
|
||||||
if( (is_a($output, 'Object')||is_subclass_of($output,'Object'))&&!$output->toBool()) return $output;
|
if( (is_a($output, 'Object')||is_subclass_of($output,'Object'))&&!$output->toBool()) return $output;
|
||||||
|
|
||||||
|
|
||||||
// action값에 따라서 쿼리 생성으로 돌입
|
// action값에 따라서 쿼리 생성으로 돌입
|
||||||
switch($output->action) {
|
switch($output->action) {
|
||||||
case 'insert' :
|
case 'insert' :
|
||||||
|
|
@ -395,5 +396,24 @@
|
||||||
break;
|
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;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -556,12 +556,38 @@
|
||||||
|
|
||||||
$condition = $this->getCondition($output);
|
$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);
|
$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(count($output->groups)) $query .= sprintf(' group by %s', implode(',',$output->groups));
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
|
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) {
|
if($output->order) {
|
||||||
foreach($output->order as $key => $val) {
|
foreach($output->order as $key => $val) {
|
||||||
$index_list[] = sprintf('%s %s', $val[0], $val[1]);
|
$index_list[] = sprintf('%s %s', $val[0], $val[1]);
|
||||||
|
|
@ -569,6 +595,8 @@
|
||||||
if(count($index_list)) $query .= ' order by '.implode(',',$index_list);
|
if(count($index_list)) $query .= ' order by '.implode(',',$index_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
$result = $this->_query($query);
|
$result = $this->_query($query);
|
||||||
if($this->isError()) return;
|
if($this->isError()) return;
|
||||||
$data = $this->_fetch($result);
|
$data = $this->_fetch($result);
|
||||||
|
|
|
||||||
|
|
@ -499,10 +499,12 @@
|
||||||
|
|
||||||
$condition = $this->getCondition($output);
|
$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에 쿼리 추가
|
// list_order, update_order 로 정렬시에 인덱스 사용을 위해 condition에 쿼리 추가
|
||||||
if($output->order) {
|
if($output->order) {
|
||||||
|
$conditions = $this->getConditionList($output);
|
||||||
|
if(!in_array('list_order', $conditions) && !in_array('update_order', $conditions)) {
|
||||||
foreach($output->order as $key => $val) {
|
foreach($output->order as $key => $val) {
|
||||||
$col = $val[0];
|
$col = $val[0];
|
||||||
if(!in_array($col, array('list_order','update_order'))) continue;
|
if(!in_array($col, array('list_order','update_order'))) continue;
|
||||||
|
|
@ -510,6 +512,7 @@
|
||||||
else $condition = sprintf(' where %s < 2100000000 ', $col);
|
else $condition = sprintf(' where %s < 2100000000 ', $col);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$query = sprintf("select %s from %s %s", $columns, implode(',',$table_list), $condition);
|
$query = sprintf("select %s from %s %s", $columns, implode(',',$table_list), $condition);
|
||||||
|
|
||||||
|
|
@ -522,6 +525,9 @@
|
||||||
if(count($index_list)) $query .= ' order by '.implode(',',$index_list);
|
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);
|
$result = $this->_query($query);
|
||||||
if($this->isError()) return;
|
if($this->isError()) return;
|
||||||
$data = $this->_fetch($result);
|
$data = $this->_fetch($result);
|
||||||
|
|
@ -562,6 +568,8 @@
|
||||||
|
|
||||||
// list_order, update_order 로 정렬시에 인덱스 사용을 위해 condition에 쿼리 추가
|
// list_order, update_order 로 정렬시에 인덱스 사용을 위해 condition에 쿼리 추가
|
||||||
if($output->order) {
|
if($output->order) {
|
||||||
|
$conditions = $this->getConditionList($output);
|
||||||
|
if(!in_array('list_order', $conditions) && !in_array('update_order', $conditions)) {
|
||||||
foreach($output->order as $key => $val) {
|
foreach($output->order as $key => $val) {
|
||||||
$col = $val[0];
|
$col = $val[0];
|
||||||
if(!in_array($col, array('list_order','update_order'))) continue;
|
if(!in_array($col, array('list_order','update_order'))) continue;
|
||||||
|
|
@ -569,6 +577,7 @@
|
||||||
else $condition = sprintf(' where %s < 2100000000 ', $col);
|
else $condition = sprintf(' where %s < 2100000000 ', $col);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$query = sprintf("select %s from %s %s", $columns, implode(',',$table_list), $condition);
|
$query = sprintf("select %s from %s %s", $columns, implode(',',$table_list), $condition);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -508,10 +508,12 @@
|
||||||
|
|
||||||
$condition = $this->getCondition($output);
|
$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에 쿼리 추가
|
// list_order, update_order 로 정렬시에 인덱스 사용을 위해 condition에 쿼리 추가
|
||||||
if($output->order) {
|
if($output->order) {
|
||||||
|
$conditions = $this->getConditionList($output);
|
||||||
|
if(!in_array('list_order', $conditions) && !in_array('update_order', $conditions)) {
|
||||||
foreach($output->order as $key => $val) {
|
foreach($output->order as $key => $val) {
|
||||||
$col = $val[0];
|
$col = $val[0];
|
||||||
if(!in_array($col, array('list_order','update_order'))) continue;
|
if(!in_array($col, array('list_order','update_order'))) continue;
|
||||||
|
|
@ -519,6 +521,7 @@
|
||||||
else $condition = sprintf(' where %s < 2100000000 ', $col);
|
else $condition = sprintf(' where %s < 2100000000 ', $col);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$query = sprintf("select %s from %s %s", $columns, implode(',',$table_list), $condition);
|
$query = sprintf("select %s from %s %s", $columns, implode(',',$table_list), $condition);
|
||||||
|
|
||||||
|
|
@ -531,6 +534,9 @@
|
||||||
if(count($index_list)) $query .= ' order by '.implode(',',$index_list);
|
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);
|
$result = $this->_query($query);
|
||||||
if($this->isError()) return;
|
if($this->isError()) return;
|
||||||
$data = $this->_fetch($result);
|
$data = $this->_fetch($result);
|
||||||
|
|
@ -571,6 +577,8 @@
|
||||||
|
|
||||||
// list_order, update_order 로 정렬시에 인덱스 사용을 위해 condition에 쿼리 추가
|
// list_order, update_order 로 정렬시에 인덱스 사용을 위해 condition에 쿼리 추가
|
||||||
if($output->order) {
|
if($output->order) {
|
||||||
|
$conditions = $this->getConditionList($output);
|
||||||
|
if(!in_array('list_order', $conditions) && !in_array('update_order', $conditions)) {
|
||||||
foreach($output->order as $key => $val) {
|
foreach($output->order as $key => $val) {
|
||||||
$col = $val[0];
|
$col = $val[0];
|
||||||
if(!in_array($col, array('list_order','update_order'))) continue;
|
if(!in_array($col, array('list_order','update_order'))) continue;
|
||||||
|
|
@ -578,6 +586,7 @@
|
||||||
else $condition = sprintf(' where %s < 2100000000 ', $col);
|
else $condition = sprintf(' where %s < 2100000000 ', $col);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$query = sprintf("select %s from %s %s", $columns, implode(',',$table_list), $condition);
|
$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(count($output->groups)) $query .= sprintf(' group by %s', implode(',',$output->groups));
|
||||||
|
|
|
||||||
|
|
@ -520,10 +520,12 @@
|
||||||
|
|
||||||
$condition = $this->getCondition($output);
|
$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에 쿼리 추가
|
// list_order, update_order 로 정렬시에 인덱스 사용을 위해 condition에 쿼리 추가
|
||||||
if($output->order) {
|
if($output->order) {
|
||||||
|
$conditions = $this->getConditionList($output);
|
||||||
|
if(!in_array('list_order', $conditions) && !in_array('update_order', $conditions)) {
|
||||||
foreach($output->order as $key => $val) {
|
foreach($output->order as $key => $val) {
|
||||||
$col = $val[0];
|
$col = $val[0];
|
||||||
if(!in_array($col, array('list_order','update_order'))) continue;
|
if(!in_array($col, array('list_order','update_order'))) continue;
|
||||||
|
|
@ -531,6 +533,7 @@
|
||||||
else $condition = sprintf(' where %s < 2100000000 ', $col);
|
else $condition = sprintf(' where %s < 2100000000 ', $col);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$query = sprintf("select %s from %s %s", $columns, implode(',',$table_list), $condition);
|
$query = sprintf("select %s from %s %s", $columns, implode(',',$table_list), $condition);
|
||||||
|
|
||||||
|
|
@ -543,6 +546,9 @@
|
||||||
if(count($index_list)) $query .= ' order by '.implode(',',$index_list);
|
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);
|
$result = $this->_query($query);
|
||||||
if($this->isError()) return;
|
if($this->isError()) return;
|
||||||
$data = $this->_fetch($result);
|
$data = $this->_fetch($result);
|
||||||
|
|
@ -583,6 +589,8 @@
|
||||||
|
|
||||||
// list_order, update_order 로 정렬시에 인덱스 사용을 위해 condition에 쿼리 추가
|
// list_order, update_order 로 정렬시에 인덱스 사용을 위해 condition에 쿼리 추가
|
||||||
if($output->order) {
|
if($output->order) {
|
||||||
|
$conditions = $this->getConditionList($output);
|
||||||
|
if(!in_array('list_order', $conditions) && !in_array('update_order', $conditions)) {
|
||||||
foreach($output->order as $key => $val) {
|
foreach($output->order as $key => $val) {
|
||||||
$col = $val[0];
|
$col = $val[0];
|
||||||
if(!in_array($col, array('list_order','update_order'))) continue;
|
if(!in_array($col, array('list_order','update_order'))) continue;
|
||||||
|
|
@ -590,6 +598,7 @@
|
||||||
else $condition = sprintf(' where %s < 2100000000 ', $col);
|
else $condition = sprintf(' where %s < 2100000000 ', $col);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$query = sprintf("select %s from %s %s", $columns, implode(',',$table_list), $condition);
|
$query = sprintf("select %s from %s %s", $columns, implode(',',$table_list), $condition);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -561,10 +561,12 @@
|
||||||
|
|
||||||
$condition = $this->getCondition($output);
|
$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에 쿼리 추가
|
// list_order, update_order 로 정렬시에 인덱스 사용을 위해 condition에 쿼리 추가
|
||||||
if($output->order) {
|
if($output->order) {
|
||||||
|
$conditions = $this->getConditionList($output);
|
||||||
|
if(!in_array('list_order', $conditions) && !in_array('update_order', $conditions)) {
|
||||||
foreach($output->order as $key => $val) {
|
foreach($output->order as $key => $val) {
|
||||||
$col = $val[0];
|
$col = $val[0];
|
||||||
if(!in_array($col, array('list_order','update_order'))) continue;
|
if(!in_array($col, array('list_order','update_order'))) continue;
|
||||||
|
|
@ -572,6 +574,7 @@
|
||||||
else $condition = sprintf(' where %s < 2100000000 ', $col);
|
else $condition = sprintf(' where %s < 2100000000 ', $col);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$query = sprintf("select %s from %s %s", $columns, implode(',',$table_list), $condition);
|
$query = sprintf("select %s from %s %s", $columns, implode(',',$table_list), $condition);
|
||||||
|
|
||||||
|
|
@ -584,6 +587,9 @@
|
||||||
if(count($index_list)) $query .= ' order by '.implode(',',$index_list);
|
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);
|
$this->_prepare($query);
|
||||||
$data = $this->_execute();
|
$data = $this->_execute();
|
||||||
if($this->isError()) return;
|
if($this->isError()) return;
|
||||||
|
|
@ -624,6 +630,8 @@
|
||||||
|
|
||||||
// list_order, update_order 로 정렬시에 인덱스 사용을 위해 condition에 쿼리 추가
|
// list_order, update_order 로 정렬시에 인덱스 사용을 위해 condition에 쿼리 추가
|
||||||
if($output->order) {
|
if($output->order) {
|
||||||
|
$conditions = $this->getConditionList($output);
|
||||||
|
if(!in_array('list_order', $conditions) && !in_array('update_order', $conditions)) {
|
||||||
foreach($output->order as $key => $val) {
|
foreach($output->order as $key => $val) {
|
||||||
$col = $val[0];
|
$col = $val[0];
|
||||||
if(!in_array($col, array('list_order','update_order'))) continue;
|
if(!in_array($col, array('list_order','update_order'))) continue;
|
||||||
|
|
@ -631,6 +639,7 @@
|
||||||
else $condition = sprintf(' where %s < 2100000000 ', $col);
|
else $condition = sprintf(' where %s < 2100000000 ', $col);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$query = sprintf("select %s from %s %s", $columns, implode(',',$table_list), $condition);
|
$query = sprintf("select %s from %s %s", $columns, implode(',',$table_list), $condition);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue