mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-09 20:12:14 +09:00
left/right outer join 지원 추가
git-svn-id: http://xe-core.googlecode.com/svn/sandbox@5199 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
56acdeca75
commit
9a029e0f8d
9 changed files with 530 additions and 260 deletions
|
|
@ -229,6 +229,20 @@
|
||||||
$xml_file = sprintf('%s%s/%s/queries/%s.xml', _XE_PATH_, $target, $module, $id);
|
$xml_file = sprintf('%s%s/%s/queries/%s.xml', _XE_PATH_, $target, $module, $id);
|
||||||
if(!file_exists($xml_file)) return new Object(-1, 'msg_invalid_queryid');
|
if(!file_exists($xml_file)) return new Object(-1, 'msg_invalid_queryid');
|
||||||
|
|
||||||
|
// 캐쉬파일을 찾아 본다
|
||||||
|
$cache_file = $this->checkQueryCacheFile($query_id,$xml_file);
|
||||||
|
|
||||||
|
// 쿼리를 실행한다
|
||||||
|
return $this->_executeQuery($cache_file, $args, $query_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 캐쉬파일을 찾아 본다
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
function checkQueryCacheFile($query_id,$xml_file){
|
||||||
|
|
||||||
// 일단 cache 파일을 찾아본다
|
// 일단 cache 파일을 찾아본다
|
||||||
$cache_file = sprintf('%s%s%s.cache.php', _XE_PATH_, $this->cache_file, $query_id);
|
$cache_file = sprintf('%s%s%s.cache.php', _XE_PATH_, $this->cache_file, $query_id);
|
||||||
if(file_exists($cache_file)) $cache_time = filemtime($cache_file);
|
if(file_exists($cache_file)) $cache_time = filemtime($cache_file);
|
||||||
|
|
@ -240,11 +254,10 @@
|
||||||
$oParser = new XmlQueryParser();
|
$oParser = new XmlQueryParser();
|
||||||
$oParser->parse($query_id, $xml_file, $cache_file);
|
$oParser->parse($query_id, $xml_file, $cache_file);
|
||||||
}
|
}
|
||||||
|
return $cache_file;
|
||||||
// 쿼리를 실행한다
|
|
||||||
return $this->_executeQuery($cache_file, $args, $query_id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 쿼리문을 실행하고 결과를 return한다
|
* @brief 쿼리문을 실행하고 결과를 return한다
|
||||||
**/
|
**/
|
||||||
|
|
@ -258,6 +271,7 @@
|
||||||
$output = @include($cache_file);
|
$output = @include($cache_file);
|
||||||
|
|
||||||
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;
|
||||||
|
$output->_tables = ($output->_tables && is_array($output->_tables)) ? $output->_tables : array();
|
||||||
|
|
||||||
|
|
||||||
// action값에 따라서 쿼리 생성으로 돌입
|
// action값에 따라서 쿼리 생성으로 돌입
|
||||||
|
|
@ -511,5 +525,17 @@
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getSupportedDatabase(){
|
||||||
|
$result = array();
|
||||||
|
if(function_exists('mysql_connect')) $result[] = 'MySQL';
|
||||||
|
if(function_exists('cubrid_connect')) $result[] = 'Cubrid';
|
||||||
|
if(function_exists('ibase_connect')) $result[] = 'FireBird';
|
||||||
|
if(function_exists('pg_connect')) $result[] = 'Postgre';
|
||||||
|
if(function_exists('sqlite_open')) $result[] = 'sqlite2';
|
||||||
|
if(function_exists('PDO')) $result[] = 'sqlite3(PDO)';
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -385,9 +385,19 @@
|
||||||
**/
|
**/
|
||||||
function getCondition($output) {
|
function getCondition($output) {
|
||||||
if(!$output->conditions) return;
|
if(!$output->conditions) return;
|
||||||
|
$condition = $this->_getCondition($output->conditions,$output->column_type);
|
||||||
|
if($condition) $condition = ' where '.$condition;
|
||||||
|
return $condition;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getLeftCondition($conditions,$column_type){
|
||||||
|
return $this->_getCondition($conditions,$column_type);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function _getCondition($conditions,$column_type) {
|
||||||
$condition = '';
|
$condition = '';
|
||||||
foreach($output->conditions as $val) {
|
foreach($conditions as $val) {
|
||||||
$sub_condition = '';
|
$sub_condition = '';
|
||||||
foreach($val['condition'] as $v) {
|
foreach($val['condition'] as $v) {
|
||||||
if(!isset($v['value'])) continue;
|
if(!isset($v['value'])) continue;
|
||||||
|
|
@ -397,30 +407,24 @@
|
||||||
$name = $v['column'];
|
$name = $v['column'];
|
||||||
$operation = $v['operation'];
|
$operation = $v['operation'];
|
||||||
$value = $v['value'];
|
$value = $v['value'];
|
||||||
$type = $this->getColumnType($output->column_type,$name);
|
$type = $this->getColumnType($column_type,$name);
|
||||||
$pipe = $v['pipe'];
|
$pipe = $v['pipe'];
|
||||||
|
|
||||||
$value = $this->getConditionValue($name, $value, $operation, $type, $output->column_type);
|
$value = $this->getConditionValue($name, $value, $operation, $type, $column_type);
|
||||||
if(!$value) $value = $v['value'];
|
if(!$value) $value = $v['value'];
|
||||||
if(strpos($name,'.')===false) $name = '"'.$name.'"';
|
|
||||||
else $name = str_replace('.','."',$name).'"';
|
|
||||||
|
|
||||||
$str = $this->getConditionPart($name, $value, $operation);
|
$str = $this->getConditionPart($name, $value, $operation);
|
||||||
|
|
||||||
if($sub_condition) $sub_condition .= ' '.$pipe.' ';
|
if($sub_condition) $sub_condition .= ' '.$pipe.' ';
|
||||||
$sub_condition .= $str;
|
$sub_condition .= $str;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($sub_condition) {
|
if($sub_condition) {
|
||||||
if($condition && $val['pipe']) $condition .= ' '.$val['pipe'].' ';
|
if($condition && $val['pipe']) $condition .= ' '.$val['pipe'].' ';
|
||||||
$condition .= '('.$sub_condition.')';
|
$condition .= '('.$sub_condition.')';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($condition) $condition = ' where '.$condition;
|
|
||||||
return $condition;
|
return $condition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief insertAct 처리
|
* @brief insertAct 처리
|
||||||
**/
|
**/
|
||||||
|
|
@ -543,6 +547,17 @@
|
||||||
$table_list[] = '"'.$this->prefix.$val.'" as '.$key;
|
$table_list[] = '"'.$this->prefix.$val.'" as '.$key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$left_join = array();
|
||||||
|
// why???
|
||||||
|
$left_tables= (array)$output->left_tables;
|
||||||
|
|
||||||
|
foreach($left_tables as $key => $val) {
|
||||||
|
$condition = $this->_getCondition($output->left_conditions[$key],$output->column_type);
|
||||||
|
if($condition){
|
||||||
|
$left_join[] = $val . ' "'.$this->prefix.$output->tables[$key].'" as '.$key . ' on (' . $condition . ')';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(!$output->columns) {
|
if(!$output->columns) {
|
||||||
$columns = '*';
|
$columns = '*';
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -572,9 +587,9 @@
|
||||||
|
|
||||||
$condition = $this->getCondition($output);
|
$condition = $this->getCondition($output);
|
||||||
|
|
||||||
if($output->list_count && $output->page) return $this->_getNavigationData($table_list, $columns, $condition, $output);
|
if($output->list_count && $output->page) return $this->_getNavigationData($table_list, $columns, $left_join, $condition, $output);
|
||||||
|
|
||||||
$query = sprintf("select %s from %s %s", $columns, implode(',',$table_list), $condition);
|
$query = sprintf("select %s from %s %s %s", $columns, implode(',',$table_list),implode(' ',$left_join), $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));
|
||||||
|
|
||||||
|
|
@ -679,11 +694,11 @@
|
||||||
*
|
*
|
||||||
* 그닥 좋지는 않은 구조이지만 편리하다.. -_-;
|
* 그닥 좋지는 않은 구조이지만 편리하다.. -_-;
|
||||||
**/
|
**/
|
||||||
function _getNavigationData($table_list, $columns, $condition, $output) {
|
function _getNavigationData($table_list, $columns, $left_join, $condition, $output) {
|
||||||
require_once(_XE_PATH_.'classes/page/PageHandler.class.php');
|
require_once(_XE_PATH_.'classes/page/PageHandler.class.php');
|
||||||
|
|
||||||
// 전체 개수를 구함
|
// 전체 개수를 구함
|
||||||
$count_query = sprintf('select count(*) as "count" from %s %s', implode(',',$table_list), $condition);
|
$count_query = sprintf("select count(*) as count from %s %s %s", implode(',',$table_list),implode(' ',$left_join), $condition);
|
||||||
$total_count = $this->getCountCache($output->tables, $condition);
|
$total_count = $this->getCountCache($output->tables, $condition);
|
||||||
if($total_count === false) {
|
if($total_count === false) {
|
||||||
$result = $this->_query($count_query);
|
$result = $this->_query($count_query);
|
||||||
|
|
@ -707,7 +722,7 @@
|
||||||
if($page > $total_page) $page = $total_page;
|
if($page > $total_page) $page = $total_page;
|
||||||
$start_count = ($page-1)*$list_count;
|
$start_count = ($page-1)*$list_count;
|
||||||
|
|
||||||
$query = sprintf("select %s from %s %s", $columns, implode(',',$table_list), $condition);
|
$query = sprintf("select %s from %s %s %s", $columns, implode(',',$table_list), implode(' ',$left_join), $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));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -598,8 +598,19 @@
|
||||||
**/
|
**/
|
||||||
function getCondition($output) {
|
function getCondition($output) {
|
||||||
if(!$output->conditions) return;
|
if(!$output->conditions) return;
|
||||||
|
$condition = $this->_getCondition($output->conditions,$output->column_type);
|
||||||
|
if($condition) $condition = ' where '.$condition;
|
||||||
|
return $condition;
|
||||||
|
}
|
||||||
|
|
||||||
foreach($output->conditions as $val) {
|
function getLeftCondition($conditions,$column_type){
|
||||||
|
return $this->_getCondition($conditions,$column_type);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function _getCondition($conditions,$column_type) {
|
||||||
|
$condition = '';
|
||||||
|
foreach($conditions as $val) {
|
||||||
$sub_condition = '';
|
$sub_condition = '';
|
||||||
foreach($val['condition'] as $v) {
|
foreach($val['condition'] as $v) {
|
||||||
if(!isset($v['value'])) continue;
|
if(!isset($v['value'])) continue;
|
||||||
|
|
@ -609,15 +620,11 @@
|
||||||
$name = $v['column'];
|
$name = $v['column'];
|
||||||
$operation = $v['operation'];
|
$operation = $v['operation'];
|
||||||
$value = $v['value'];
|
$value = $v['value'];
|
||||||
$type = $this->getColumnType($output->column_type,$name);
|
$type = $this->getColumnType($column_type,$name);
|
||||||
$pipe = $v['pipe'];
|
$pipe = $v['pipe'];
|
||||||
|
|
||||||
$value = $this->getConditionValue('"'.$name.'"', $value, $operation, $type, $output->column_type);
|
$value = $this->getConditionValue($name, $value, $operation, $type, $column_type);
|
||||||
if(!$value) $value = $v['value'];
|
if(!$value) $value = $v['value'];
|
||||||
|
|
||||||
$name = $this->autoQuotes($name);
|
|
||||||
$value = $this->autoValueQuotes($value, $output);
|
|
||||||
|
|
||||||
$str = $this->getConditionPart($name, $value, $operation);
|
$str = $this->getConditionPart($name, $value, $operation);
|
||||||
if($sub_condition) $sub_condition .= ' '.$pipe.' ';
|
if($sub_condition) $sub_condition .= ' '.$pipe.' ';
|
||||||
$sub_condition .= $str;
|
$sub_condition .= $str;
|
||||||
|
|
@ -627,8 +634,6 @@
|
||||||
$condition .= '('.$sub_condition.')';
|
$condition .= '('.$sub_condition.')';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($condition) $condition = ' Where '.$condition;
|
|
||||||
return $condition;
|
return $condition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -755,6 +760,18 @@
|
||||||
$table_list[] = sprintf("\"%s%s\" as \"%s\"", $this->prefix, $val, $key);
|
$table_list[] = sprintf("\"%s%s\" as \"%s\"", $this->prefix, $val, $key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$left_join = array();
|
||||||
|
// why???
|
||||||
|
$left_tables= (array)$output->left_tables;
|
||||||
|
|
||||||
|
foreach($left_tables as $key => $val) {
|
||||||
|
$condition = $this->_getCondition($output->left_conditions[$key],$output->column_type);
|
||||||
|
if($condition){
|
||||||
|
$left_join[] = $val . ' "'.$this->prefix.$output->_tables[$key].'" as '.$key . ' on (' . $condition . ')';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if(!$output->columns) {
|
if(!$output->columns) {
|
||||||
$columns = '*';
|
$columns = '*';
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -773,7 +790,7 @@
|
||||||
|
|
||||||
$condition = $this->getCondition($output);
|
$condition = $this->getCondition($output);
|
||||||
|
|
||||||
if($output->list_count && $output->page) return $this->_getNavigationData($table_list, $columns, $condition, $output);
|
if($output->list_count && $output->page) return $this->_getNavigationData($table_list, $columns, $left_join, $condition, $output);
|
||||||
|
|
||||||
// list_order, update_order 로 정렬시에 인덱스 사용을 위해 condition에 쿼리 추가
|
// list_order, update_order 로 정렬시에 인덱스 사용을 위해 condition에 쿼리 추가
|
||||||
if($output->order) {
|
if($output->order) {
|
||||||
|
|
@ -792,7 +809,7 @@
|
||||||
if($output->list_count['value']) $limit = sprintf('FIRST %d', $output->list_count['value']);
|
if($output->list_count['value']) $limit = sprintf('FIRST %d', $output->list_count['value']);
|
||||||
else $limit = '';
|
else $limit = '';
|
||||||
|
|
||||||
$query = sprintf("select %s %s from %s %s", $limit, $columns, implode(',',$table_list), $condition);
|
$query = sprintf("select %s from %s %s %s", $columns, implode(',',$table_list),implode(' ',$left_join), $condition);
|
||||||
|
|
||||||
if($output->groups) {
|
if($output->groups) {
|
||||||
foreach($output->groups as $key => $val) {
|
foreach($output->groups as $key => $val) {
|
||||||
|
|
@ -825,11 +842,11 @@
|
||||||
*
|
*
|
||||||
* 그닥 좋지는 않은 구조이지만 편리하다.. -_-;
|
* 그닥 좋지는 않은 구조이지만 편리하다.. -_-;
|
||||||
**/
|
**/
|
||||||
function _getNavigationData($table_list, $columns, $condition, $output) {
|
function _getNavigationData($table_list, $columns, $left_join, $condition, $output) {
|
||||||
require_once(_XE_PATH_.'classes/page/PageHandler.class.php');
|
require_once(_XE_PATH_.'classes/page/PageHandler.class.php');
|
||||||
|
|
||||||
// 전체 개수를 구함
|
// 전체 개수를 구함
|
||||||
$count_query = sprintf('select count(*) as "count" from %s %s;', implode(',',$table_list), $condition);
|
$count_query = sprintf("select count(*) as count from %s %s %s", implode(',',$table_list),implode(' ',$left_join), $condition);
|
||||||
$total_count = $this->getCountCache($output->tables, $condition);
|
$total_count = $this->getCountCache($output->tables, $condition);
|
||||||
if($total_count === false) {
|
if($total_count === false) {
|
||||||
$result = $this->_query($count_query);
|
$result = $this->_query($count_query);
|
||||||
|
|
@ -869,7 +886,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
$limit = sprintf('FIRST %d SKIP %d ', $list_count, $start_count);
|
$limit = sprintf('FIRST %d SKIP %d ', $list_count, $start_count);
|
||||||
$query = sprintf('SELECT %s %s FROM %s %s', $limit, $columns, implode(',',$table_list), $condition);
|
$query = sprintf('SELECT %s %s FROM %s %s %s', $limit, $columns, implode(',',$table_list), implode(' ',$left_join), $condition);
|
||||||
|
|
||||||
if($output->groups) {
|
if($output->groups) {
|
||||||
foreach($output->groups as $key => $val) {
|
foreach($output->groups as $key => $val) {
|
||||||
|
|
|
||||||
|
|
@ -376,8 +376,19 @@
|
||||||
**/
|
**/
|
||||||
function getCondition($output) {
|
function getCondition($output) {
|
||||||
if(!$output->conditions) return;
|
if(!$output->conditions) return;
|
||||||
|
$condition = $this->_getCondition($output->conditions,$output->column_type);
|
||||||
|
if($condition) $condition = ' where '.$condition;
|
||||||
|
return $condition;
|
||||||
|
}
|
||||||
|
|
||||||
foreach($output->conditions as $val) {
|
function getLeftCondition($conditions,$column_type){
|
||||||
|
return $this->_getCondition($conditions,$column_type);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function _getCondition($conditions,$column_type) {
|
||||||
|
$condition = '';
|
||||||
|
foreach($conditions as $val) {
|
||||||
$sub_condition = '';
|
$sub_condition = '';
|
||||||
foreach($val['condition'] as $v) {
|
foreach($val['condition'] as $v) {
|
||||||
if(!isset($v['value'])) continue;
|
if(!isset($v['value'])) continue;
|
||||||
|
|
@ -387,10 +398,9 @@
|
||||||
$name = $v['column'];
|
$name = $v['column'];
|
||||||
$operation = $v['operation'];
|
$operation = $v['operation'];
|
||||||
$value = $v['value'];
|
$value = $v['value'];
|
||||||
$type = $this->getColumnType($output->column_type,$name);
|
$type = $this->getColumnType($column_type,$name);
|
||||||
$pipe = $v['pipe'];
|
$pipe = $v['pipe'];
|
||||||
|
$value = $this->getConditionValue($name, $value, $operation, $type, $column_type);
|
||||||
$value = $this->getConditionValue($name, $value, $operation, $type, $output->column_type);
|
|
||||||
if(!$value) $value = $v['value'];
|
if(!$value) $value = $v['value'];
|
||||||
$str = $this->getConditionPart($name, $value, $operation);
|
$str = $this->getConditionPart($name, $value, $operation);
|
||||||
if($sub_condition) $sub_condition .= ' '.$pipe.' ';
|
if($sub_condition) $sub_condition .= ' '.$pipe.' ';
|
||||||
|
|
@ -401,8 +411,6 @@
|
||||||
$condition .= '('.$sub_condition.')';
|
$condition .= '('.$sub_condition.')';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($condition) $condition = ' where '.$condition;
|
|
||||||
return $condition;
|
return $condition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -493,6 +501,16 @@
|
||||||
$table_list[] = '`'.$this->prefix.$val.'` as '.$key;
|
$table_list[] = '`'.$this->prefix.$val.'` as '.$key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$left_join = array();
|
||||||
|
// why???
|
||||||
|
$left_tables= (array)$output->left_tables;
|
||||||
|
foreach($left_tables as $key => $val) {
|
||||||
|
$condition = $this->_getCondition($output->left_conditions[$key],$output->column_type);
|
||||||
|
if($condition){
|
||||||
|
$left_join[] = $val . ' `'.$this->prefix.$output->_tables[$key].'` as '.$key . ' on (' . $condition . ')';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(!$output->columns) {
|
if(!$output->columns) {
|
||||||
$columns = '*';
|
$columns = '*';
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -515,7 +533,7 @@
|
||||||
|
|
||||||
$condition = $this->getCondition($output);
|
$condition = $this->getCondition($output);
|
||||||
|
|
||||||
if($output->list_count && $output->page) return $this->_getNavigationData($table_list, $columns, $condition, $output);
|
if($output->list_count && $output->page) return $this->_getNavigationData($table_list, $columns, $left_join, $condition, $output);
|
||||||
|
|
||||||
// list_order, update_order 로 정렬시에 인덱스 사용을 위해 condition에 쿼리 추가
|
// list_order, update_order 로 정렬시에 인덱스 사용을 위해 condition에 쿼리 추가
|
||||||
if($output->order) {
|
if($output->order) {
|
||||||
|
|
@ -530,7 +548,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = sprintf("select %s from %s %s", $columns, implode(',',$table_list), $condition);
|
$query = sprintf("select %s from %s %s %s", $columns, implode(',',$table_list),implode(' ',$left_join), $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));
|
||||||
|
|
||||||
|
|
@ -558,11 +576,11 @@
|
||||||
*
|
*
|
||||||
* 그닥 좋지는 않은 구조이지만 편리하다.. -_-;
|
* 그닥 좋지는 않은 구조이지만 편리하다.. -_-;
|
||||||
**/
|
**/
|
||||||
function _getNavigationData($table_list, $columns, $condition, $output) {
|
function _getNavigationData($table_list, $columns, $left_join, $condition, $output) {
|
||||||
require_once(_XE_PATH_.'classes/page/PageHandler.class.php');
|
require_once(_XE_PATH_.'classes/page/PageHandler.class.php');
|
||||||
|
|
||||||
// 전체 개수를 구함
|
// 전체 개수를 구함
|
||||||
$count_query = sprintf("select count(*) as count from %s %s", implode(',',$table_list), $condition);
|
$count_query = sprintf("select count(*) as count from %s %s %s", implode(',',$table_list),implode(' ',$left_join), $condition);
|
||||||
$total_count = $this->getCountCache($output->tables, $condition);
|
$total_count = $this->getCountCache($output->tables, $condition);
|
||||||
if($total_count === false) {
|
if($total_count === false) {
|
||||||
$result = $this->_query($count_query);
|
$result = $this->_query($count_query);
|
||||||
|
|
@ -599,7 +617,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = sprintf("select %s from %s %s", $columns, implode(',',$table_list), $condition);
|
$query = sprintf("select %s from %s %s %s", $columns, implode(',',$table_list), implode(' ',$left_join), $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));
|
||||||
|
|
||||||
|
|
@ -611,7 +629,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = sprintf('%s limit %d, %d', $query, $start_count, $list_count);
|
$query = sprintf('%s limit %d, %d', $query, $start_count, $list_count);
|
||||||
|
|
||||||
$result = $this->_query($query);
|
$result = $this->_query($query);
|
||||||
if($this->isError()) {
|
if($this->isError()) {
|
||||||
$buff = new Object();
|
$buff = new Object();
|
||||||
|
|
|
||||||
|
|
@ -385,8 +385,19 @@
|
||||||
**/
|
**/
|
||||||
function getCondition($output) {
|
function getCondition($output) {
|
||||||
if(!$output->conditions) return;
|
if(!$output->conditions) return;
|
||||||
|
$condition = $this->_getCondition($output->conditions,$output->column_type);
|
||||||
|
if($condition) $condition = ' where '.$condition;
|
||||||
|
return $condition;
|
||||||
|
}
|
||||||
|
|
||||||
foreach($output->conditions as $val) {
|
function getLeftCondition($conditions,$column_type){
|
||||||
|
return $this->_getCondition($conditions,$column_type);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function _getCondition($conditions,$column_type) {
|
||||||
|
$condition = '';
|
||||||
|
foreach($conditions as $val) {
|
||||||
$sub_condition = '';
|
$sub_condition = '';
|
||||||
foreach($val['condition'] as $v) {
|
foreach($val['condition'] as $v) {
|
||||||
if(!isset($v['value'])) continue;
|
if(!isset($v['value'])) continue;
|
||||||
|
|
@ -396,10 +407,10 @@
|
||||||
$name = $v['column'];
|
$name = $v['column'];
|
||||||
$operation = $v['operation'];
|
$operation = $v['operation'];
|
||||||
$value = $v['value'];
|
$value = $v['value'];
|
||||||
$type = $this->getColumnType($output->column_type,$name);
|
$type = $this->getColumnType($column_type,$name);
|
||||||
$pipe = $v['pipe'];
|
$pipe = $v['pipe'];
|
||||||
|
|
||||||
$value = $this->getConditionValue($name, $value, $operation, $type, $output->column_type);
|
$value = $this->getConditionValue($name, $value, $operation, $type, $column_type);
|
||||||
if(!$value) $value = $v['value'];
|
if(!$value) $value = $v['value'];
|
||||||
$str = $this->getConditionPart($name, $value, $operation);
|
$str = $this->getConditionPart($name, $value, $operation);
|
||||||
if($sub_condition) $sub_condition .= ' '.$pipe.' ';
|
if($sub_condition) $sub_condition .= ' '.$pipe.' ';
|
||||||
|
|
@ -410,8 +421,6 @@
|
||||||
$condition .= '('.$sub_condition.')';
|
$condition .= '('.$sub_condition.')';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($condition) $condition = ' where '.$condition;
|
|
||||||
return $condition;
|
return $condition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -502,6 +511,17 @@
|
||||||
$table_list[] = '`'.$this->prefix.$val.'` as '.$key;
|
$table_list[] = '`'.$this->prefix.$val.'` as '.$key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$left_join = array();
|
||||||
|
// why???
|
||||||
|
$left_tables= (array)$output->left_tables;
|
||||||
|
|
||||||
|
foreach($left_tables as $key => $val) {
|
||||||
|
$condition = $this->_getCondition($output->left_conditions[$key],$output->column_type);
|
||||||
|
if($condition){
|
||||||
|
$left_join[] = $val . ' `'.$this->prefix.$output->_tables[$key].'` as '.$key . ' on (' . $condition . ')';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(!$output->columns) {
|
if(!$output->columns) {
|
||||||
$columns = '*';
|
$columns = '*';
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -524,7 +544,8 @@
|
||||||
|
|
||||||
$condition = $this->getCondition($output);
|
$condition = $this->getCondition($output);
|
||||||
|
|
||||||
if($output->list_count && $output->page) return $this->_getNavigationData($table_list, $columns, $condition, $output);
|
if($output->list_count && $output->page) return $this->_getNavigationData($table_list, $columns, $left_join, $condition, $output);
|
||||||
|
|
||||||
|
|
||||||
// list_order, update_order 로 정렬시에 인덱스 사용을 위해 condition에 쿼리 추가
|
// list_order, update_order 로 정렬시에 인덱스 사용을 위해 condition에 쿼리 추가
|
||||||
if($output->order) {
|
if($output->order) {
|
||||||
|
|
@ -539,7 +560,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = sprintf("select %s from %s %s", $columns, implode(',',$table_list), $condition);
|
$query = sprintf("select %s from %s %s %s", $columns, implode(',',$table_list),implode(' ',$left_join), $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));
|
||||||
|
|
||||||
|
|
@ -567,11 +588,11 @@
|
||||||
*
|
*
|
||||||
* 그닥 좋지는 않은 구조이지만 편리하다.. -_-;
|
* 그닥 좋지는 않은 구조이지만 편리하다.. -_-;
|
||||||
**/
|
**/
|
||||||
function _getNavigationData($table_list, $columns, $condition, $output) {
|
function _getNavigationData($table_list, $columns, $left_join, $condition, $output) {
|
||||||
require_once(_XE_PATH_.'classes/page/PageHandler.class.php');
|
require_once(_XE_PATH_.'classes/page/PageHandler.class.php');
|
||||||
|
|
||||||
// 전체 개수를 구함
|
// 전체 개수를 구함
|
||||||
$count_query = sprintf("select count(*) as count from %s %s", implode(',',$table_list), $condition);
|
$count_query = sprintf("select count(*) as count from %s %s %s", implode(',',$table_list),implode(' ',$left_join), $condition);
|
||||||
$total_count = $this->getCountCache($output->tables, $condition);
|
$total_count = $this->getCountCache($output->tables, $condition);
|
||||||
if($total_count === false) {
|
if($total_count === false) {
|
||||||
$result = $this->_query($count_query);
|
$result = $this->_query($count_query);
|
||||||
|
|
@ -608,7 +629,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = sprintf("select %s from %s %s", $columns, implode(',',$table_list), $condition);
|
$query = sprintf("select %s from %s %s %s", $columns, implode(',',$table_list), implode(' ',$left_join), $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));
|
||||||
|
|
||||||
if($output->order) {
|
if($output->order) {
|
||||||
|
|
|
||||||
|
|
@ -381,8 +381,19 @@
|
||||||
**/
|
**/
|
||||||
function getCondition($output) {
|
function getCondition($output) {
|
||||||
if(!$output->conditions) return;
|
if(!$output->conditions) return;
|
||||||
|
$condition = $this->_getCondition($output->conditions,$output->column_type);
|
||||||
|
if($condition) $condition = ' where '.$condition;
|
||||||
|
return $condition;
|
||||||
|
}
|
||||||
|
|
||||||
foreach($output->conditions as $val) {
|
function getLeftCondition($conditions,$column_type){
|
||||||
|
return $this->_getCondition($conditions,$column_type);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function _getCondition($conditions,$column_type) {
|
||||||
|
$condition = '';
|
||||||
|
foreach($conditions as $val) {
|
||||||
$sub_condition = '';
|
$sub_condition = '';
|
||||||
foreach($val['condition'] as $v) {
|
foreach($val['condition'] as $v) {
|
||||||
if(!isset($v['value'])) continue;
|
if(!isset($v['value'])) continue;
|
||||||
|
|
@ -392,10 +403,10 @@
|
||||||
$name = $v['column'];
|
$name = $v['column'];
|
||||||
$operation = $v['operation'];
|
$operation = $v['operation'];
|
||||||
$value = $v['value'];
|
$value = $v['value'];
|
||||||
$type = $this->getColumnType($output->column_type,$name);
|
$type = $this->getColumnType($column_type,$name);
|
||||||
$pipe = $v['pipe'];
|
$pipe = $v['pipe'];
|
||||||
|
|
||||||
$value = $this->getConditionValue($name, $value, $operation, $type, $output->column_type);
|
$value = $this->getConditionValue($name, $value, $operation, $type, $column_type);
|
||||||
if(!$value) $value = $v['value'];
|
if(!$value) $value = $v['value'];
|
||||||
$str = $this->getConditionPart($name, $value, $operation);
|
$str = $this->getConditionPart($name, $value, $operation);
|
||||||
if($sub_condition) $sub_condition .= ' '.$pipe.' ';
|
if($sub_condition) $sub_condition .= ' '.$pipe.' ';
|
||||||
|
|
@ -406,11 +417,10 @@
|
||||||
$condition .= '('.$sub_condition.')';
|
$condition .= '('.$sub_condition.')';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($condition) $condition = ' where '.$condition;
|
|
||||||
return $condition;
|
return $condition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief insertAct 처리
|
* @brief insertAct 처리
|
||||||
**/
|
**/
|
||||||
|
|
@ -498,6 +508,18 @@
|
||||||
$table_list[] = $this->prefix.$val.' as '.$key;
|
$table_list[] = $this->prefix.$val.' as '.$key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$left_join = array();
|
||||||
|
// why???
|
||||||
|
$left_tables= (array)$output->left_tables;
|
||||||
|
|
||||||
|
foreach($left_tables as $key => $val) {
|
||||||
|
$condition = $this->_getCondition($output->left_conditions[$key],$output->column_type);
|
||||||
|
if($condition){
|
||||||
|
$left_join[] = $val . ' '.$this->prefix.$output->_tables[$key].' as '.$key . ' on (' . $condition . ')';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if(!$output->columns) {
|
if(!$output->columns) {
|
||||||
$columns = '*';
|
$columns = '*';
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -520,7 +542,7 @@
|
||||||
|
|
||||||
$condition = $this->getCondition($output);
|
$condition = $this->getCondition($output);
|
||||||
|
|
||||||
if($output->list_count && $output->page) return $this->_getNavigationData($table_list, $columns, $condition, $output);
|
if($output->list_count && $output->page) return $this->_getNavigationData($table_list, $columns, $left_join, $condition, $output);
|
||||||
|
|
||||||
// list_order, update_order 로 정렬시에 인덱스 사용을 위해 condition에 쿼리 추가
|
// list_order, update_order 로 정렬시에 인덱스 사용을 위해 condition에 쿼리 추가
|
||||||
if($output->order) {
|
if($output->order) {
|
||||||
|
|
@ -535,7 +557,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = sprintf("select %s from %s %s", $columns, implode(',',$table_list), $condition);
|
$query = sprintf("select %s from %s %s %s", $columns, implode(',',$table_list),implode(' ',$left_join), $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));
|
||||||
|
|
||||||
|
|
@ -560,11 +582,11 @@
|
||||||
*
|
*
|
||||||
* 그닥 좋지는 않은 구조이지만 편리하다.. -_-;
|
* 그닥 좋지는 않은 구조이지만 편리하다.. -_-;
|
||||||
**/
|
**/
|
||||||
function _getNavigationData($table_list, $columns, $condition, $output) {
|
function _getNavigationData($table_list, $columns, $left_join, $condition, $output) {
|
||||||
require_once(_XE_PATH_.'classes/page/PageHandler.class.php');
|
require_once(_XE_PATH_.'classes/page/PageHandler.class.php');
|
||||||
|
|
||||||
// 전체 개수를 구함
|
// 전체 개수를 구함
|
||||||
$count_query = sprintf("select count(*) as count from %s %s", implode(',',$table_list), $condition);
|
$count_query = sprintf("select count(*) as count from %s %s %s", implode(',',$table_list),implode(' ',$left_join), $condition);
|
||||||
$total_count = $this->getCountCache($output->tables, $condition);
|
$total_count = $this->getCountCache($output->tables, $condition);
|
||||||
if($total_count === false) {
|
if($total_count === false) {
|
||||||
$result = $this->_query($count_query);
|
$result = $this->_query($count_query);
|
||||||
|
|
@ -601,7 +623,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = sprintf("select %s from %s %s", $columns, implode(',',$table_list), $condition);
|
$query = sprintf("select %s from %s %s %s", $columns, implode(',',$table_list), implode(' ',$left_join), $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));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -357,8 +357,19 @@
|
||||||
**/
|
**/
|
||||||
function getCondition($output) {
|
function getCondition($output) {
|
||||||
if(!$output->conditions) return;
|
if(!$output->conditions) return;
|
||||||
|
$condition = $this->_getCondition($output->conditions,$output->column_type);
|
||||||
|
if($condition) $condition = ' where '.$condition;
|
||||||
|
return $condition;
|
||||||
|
}
|
||||||
|
|
||||||
foreach($output->conditions as $val) {
|
function getLeftCondition($conditions,$column_type){
|
||||||
|
return $this->_getCondition($conditions,$column_type);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function _getCondition($conditions,$column_type) {
|
||||||
|
$condition = '';
|
||||||
|
foreach($conditions as $val) {
|
||||||
$sub_condition = '';
|
$sub_condition = '';
|
||||||
foreach($val['condition'] as $v) {
|
foreach($val['condition'] as $v) {
|
||||||
if(!isset($v['value'])) continue;
|
if(!isset($v['value'])) continue;
|
||||||
|
|
@ -368,10 +379,10 @@
|
||||||
$name = $v['column'];
|
$name = $v['column'];
|
||||||
$operation = $v['operation'];
|
$operation = $v['operation'];
|
||||||
$value = $v['value'];
|
$value = $v['value'];
|
||||||
$type = $this->getColumnType($output->column_type,$name);
|
$type = $this->getColumnType($column_type,$name);
|
||||||
$pipe = $v['pipe'];
|
$pipe = $v['pipe'];
|
||||||
|
|
||||||
$value = $this->getConditionValue($name, $value, $operation, $type, $output->column_type);
|
$value = $this->getConditionValue($name, $value, $operation, $type, $column_type);
|
||||||
if(!$value) $value = $v['value'];
|
if(!$value) $value = $v['value'];
|
||||||
$str = $this->getConditionPart($name, $value, $operation);
|
$str = $this->getConditionPart($name, $value, $operation);
|
||||||
if($sub_condition) $sub_condition .= ' '.$pipe.' ';
|
if($sub_condition) $sub_condition .= ' '.$pipe.' ';
|
||||||
|
|
@ -382,8 +393,6 @@
|
||||||
$condition .= '('.$sub_condition.')';
|
$condition .= '('.$sub_condition.')';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($condition) $condition = ' where '.$condition;
|
|
||||||
return $condition;
|
return $condition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -509,6 +518,17 @@
|
||||||
$table_list[] = $this->prefix.$val.' as '.$key;
|
$table_list[] = $this->prefix.$val.' as '.$key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$left_join = array();
|
||||||
|
// why???
|
||||||
|
$left_tables= (array)$output->left_tables;
|
||||||
|
|
||||||
|
foreach($left_tables as $key => $val) {
|
||||||
|
$condition = $this->_getCondition($output->left_conditions[$key],$output->column_type);
|
||||||
|
if($condition){
|
||||||
|
$left_join[] = $val . ' '.$this->prefix.$output->_tables[$key].' as '.$key . ' on ' . $condition . '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(!$output->columns) {
|
if(!$output->columns) {
|
||||||
$columns = '*';
|
$columns = '*';
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -531,7 +551,7 @@
|
||||||
|
|
||||||
$condition = $this->getCondition($output);
|
$condition = $this->getCondition($output);
|
||||||
|
|
||||||
if($output->list_count && $output->page) return $this->_getNavigationData($table_list, $columns, $condition, $output);
|
if($output->list_count && $output->page) return $this->_getNavigationData($table_list, $columns, $left_join, $condition, $output);
|
||||||
|
|
||||||
// list_order, update_order 로 정렬시에 인덱스 사용을 위해 condition에 쿼리 추가
|
// list_order, update_order 로 정렬시에 인덱스 사용을 위해 condition에 쿼리 추가
|
||||||
if($output->order) {
|
if($output->order) {
|
||||||
|
|
@ -546,7 +566,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = sprintf("select %s from %s %s", $columns, implode(',',$table_list), $condition);
|
$query = sprintf("select %s from %s %s %s", $columns, implode(',',$table_list),implode(' ',$left_join), $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));
|
||||||
|
|
||||||
|
|
@ -574,12 +594,14 @@
|
||||||
*
|
*
|
||||||
* 그닥 좋지는 않은 구조이지만 편리하다.. -_-;
|
* 그닥 좋지는 않은 구조이지만 편리하다.. -_-;
|
||||||
**/
|
**/
|
||||||
function _getNavigationData($table_list, $columns, $condition, $output) {
|
function _getNavigationData($table_list, $columns, $left_join, $condition, $output) {
|
||||||
require_once(_XE_PATH_.'classes/page/PageHandler.class.php');
|
require_once(_XE_PATH_.'classes/page/PageHandler.class.php');
|
||||||
|
|
||||||
// 전체 개수를 구함
|
// 전체 개수를 구함
|
||||||
$count_query = sprintf("select count(*) as count from %s %s", implode(',',$table_list), $condition);
|
$count_query = sprintf("select count(*) as count from %s %s %s", implode(',',$table_list),implode(' ',$left_join), $condition);
|
||||||
|
|
||||||
$total_count = $this->getCountCache($output->tables, $condition);
|
$total_count = $this->getCountCache($output->tables, $condition);
|
||||||
|
|
||||||
if($total_count === false) {
|
if($total_count === false) {
|
||||||
$result = $this->_query($count_query);
|
$result = $this->_query($count_query);
|
||||||
$count_output = $this->_fetch($result);
|
$count_output = $this->_fetch($result);
|
||||||
|
|
@ -615,7 +637,8 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = sprintf("select %s from %s %s", $columns, implode(',',$table_list), $condition);
|
$query = sprintf("select %s from %s %s %s", $columns, implode(',',$table_list), implode(' ',$left_join), $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));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -386,8 +386,19 @@
|
||||||
**/
|
**/
|
||||||
function getCondition($output) {
|
function getCondition($output) {
|
||||||
if(!$output->conditions) return;
|
if(!$output->conditions) return;
|
||||||
|
$condition = $this->_getCondition($output->conditions,$output->column_type);
|
||||||
|
if($condition) $condition = ' where '.$condition;
|
||||||
|
return $condition;
|
||||||
|
}
|
||||||
|
|
||||||
foreach($output->conditions as $val) {
|
function getLeftCondition($conditions,$column_type){
|
||||||
|
return $this->_getCondition($conditions,$column_type);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function _getCondition($conditions,$column_type) {
|
||||||
|
$condition = '';
|
||||||
|
foreach($conditions as $val) {
|
||||||
$sub_condition = '';
|
$sub_condition = '';
|
||||||
foreach($val['condition'] as $v) {
|
foreach($val['condition'] as $v) {
|
||||||
if(!isset($v['value'])) continue;
|
if(!isset($v['value'])) continue;
|
||||||
|
|
@ -397,12 +408,11 @@
|
||||||
$name = $v['column'];
|
$name = $v['column'];
|
||||||
$operation = $v['operation'];
|
$operation = $v['operation'];
|
||||||
$value = $v['value'];
|
$value = $v['value'];
|
||||||
$type = $this->getColumnType($output->column_type,$name);
|
$type = $this->getColumnType($column_type,$name);
|
||||||
$pipe = $v['pipe'];
|
$pipe = $v['pipe'];
|
||||||
|
|
||||||
$value = $this->getConditionValue($name, $value, $operation, $type, $output->column_type);
|
$value = $this->getConditionValue($name, $value, $operation, $type, $column_type);
|
||||||
if(!$value) $value = $v['value'];
|
if(!$value) $value = $v['value'];
|
||||||
|
|
||||||
$str = $this->getConditionPart($name, $value, $operation);
|
$str = $this->getConditionPart($name, $value, $operation);
|
||||||
if($sub_condition) $sub_condition .= ' '.$pipe.' ';
|
if($sub_condition) $sub_condition .= ' '.$pipe.' ';
|
||||||
$sub_condition .= $str;
|
$sub_condition .= $str;
|
||||||
|
|
@ -412,8 +422,6 @@
|
||||||
$condition .= '('.$sub_condition.')';
|
$condition .= '('.$sub_condition.')';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($condition) $condition = ' where '.$condition;
|
|
||||||
return $condition;
|
return $condition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -550,6 +558,19 @@
|
||||||
$table_list[] = $this->prefix.$val.' as '.$key;
|
$table_list[] = $this->prefix.$val.' as '.$key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$left_join = array();
|
||||||
|
// why???
|
||||||
|
$left_tables= (array)$output->left_tables;
|
||||||
|
|
||||||
|
foreach($left_tables as $key => $val) {
|
||||||
|
$condition = $this->_getCondition($output->left_conditions[$key],$output->column_type);
|
||||||
|
if($condition){
|
||||||
|
$left_join[] = $val . ' '.$this->prefix.$output->_tables[$key].' as '.$key . ' on (' . $condition . ')';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(!$output->columns) {
|
if(!$output->columns) {
|
||||||
$columns = '*';
|
$columns = '*';
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -572,7 +593,7 @@
|
||||||
|
|
||||||
$condition = $this->getCondition($output);
|
$condition = $this->getCondition($output);
|
||||||
|
|
||||||
if($output->list_count && $output->page) return $this->_getNavigationData($table_list, $columns, $condition, $output);
|
if($output->list_count && $output->page) return $this->_getNavigationData($table_list, $columns, ,$left_join, $condition, $output);
|
||||||
|
|
||||||
// list_order, update_order 로 정렬시에 인덱스 사용을 위해 condition에 쿼리 추가
|
// list_order, update_order 로 정렬시에 인덱스 사용을 위해 condition에 쿼리 추가
|
||||||
if($output->order) {
|
if($output->order) {
|
||||||
|
|
@ -587,7 +608,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = sprintf("select %s from %s %s", $columns, implode(',',$table_list), $condition);
|
$query = sprintf("select %s from %s %s %s", $columns, implode(',',$table_list),implode(' ',$left_join), $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));
|
||||||
|
|
||||||
|
|
@ -615,11 +636,11 @@
|
||||||
*
|
*
|
||||||
* 그닥 좋지는 않은 구조이지만 편리하다.. -_-;
|
* 그닥 좋지는 않은 구조이지만 편리하다.. -_-;
|
||||||
**/
|
**/
|
||||||
function _getNavigationData($table_list, $columns, $condition, $output) {
|
function _getNavigationData($table_list, $columns, $left_join, $condition, $output) {
|
||||||
require_once(_XE_PATH_.'classes/page/PageHandler.class.php');
|
require_once(_XE_PATH_.'classes/page/PageHandler.class.php');
|
||||||
|
|
||||||
// 전체 개수를 구함
|
// 전체 개수를 구함
|
||||||
$count_query = sprintf("select count(*) as count from %s %s", implode(',',$table_list), $condition);
|
$count_query = sprintf("select count(*) as count from %s %s %s", implode(',',$table_list),implode(' ',$left_join), $condition);
|
||||||
$total_count = $this->getCountCache($output->tables, $condition);
|
$total_count = $this->getCountCache($output->tables, $condition);
|
||||||
if($total_count === false) {
|
if($total_count === false) {
|
||||||
$this->_prepare($count_query);
|
$this->_prepare($count_query);
|
||||||
|
|
@ -656,7 +677,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = sprintf("select %s from %s %s", $columns, implode(',',$table_list), $condition);
|
$query = sprintf("select %s from %s %s %s", $columns, implode(',',$table_list), implode(' ',$left_join), $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));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,9 +38,14 @@
|
||||||
|
|
||||||
// 테이블 정리 (배열코드로 변환)
|
// 테이블 정리 (배열코드로 변환)
|
||||||
$tables = $xml_obj->query->tables->table;
|
$tables = $xml_obj->query->tables->table;
|
||||||
|
$output->left_tables = array();
|
||||||
|
|
||||||
|
$left_conditions = array();
|
||||||
|
|
||||||
if(!$tables) return;
|
if(!$tables) return;
|
||||||
if(!is_array($tables)) $tables = array($tables);
|
if(!is_array($tables)) $tables = array($tables);
|
||||||
foreach($tables as $key => $val) {
|
foreach($tables as $key => $val) {
|
||||||
|
|
||||||
// 테이블과 alias의 이름을 구함
|
// 테이블과 alias의 이름을 구함
|
||||||
$table_name = $val->attrs->name;
|
$table_name = $val->attrs->name;
|
||||||
$alias = $val->attrs->alias;
|
$alias = $val->attrs->alias;
|
||||||
|
|
@ -48,6 +53,11 @@
|
||||||
|
|
||||||
$output->tables[$alias] = $table_name;
|
$output->tables[$alias] = $table_name;
|
||||||
|
|
||||||
|
if(in_array($val->attrs->type,array('left join','left outer join','right join','right outer join')) && count($val->conditions)){
|
||||||
|
$output->left_tables[$alias] = $val->attrs->type;
|
||||||
|
$left_conditions[$alias] = $val->conditions;
|
||||||
|
}
|
||||||
|
|
||||||
// 테이블을 찾아서 컬럼의 속성을 구함
|
// 테이블을 찾아서 컬럼의 속성을 구함
|
||||||
$table_file = sprintf('%s%s/%s/schemas/%s.xml', _XE_PATH_, 'modules', $module, $table_name);
|
$table_file = sprintf('%s%s/%s/schemas/%s.xml', _XE_PATH_, 'modules', $module, $table_name);
|
||||||
if(!file_exists($table_file)) {
|
if(!file_exists($table_file)) {
|
||||||
|
|
@ -75,167 +85,92 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 컬럼 정리
|
// 컬럼 정리
|
||||||
$columns = $xml_obj->query->columns->column;
|
$columns = $xml_obj->query->columns->column;
|
||||||
if(!$columns) {
|
$out = $this->_setColumn($columns);
|
||||||
$output->column[] = array("*" => "*");
|
$output->columns = $out->columns;
|
||||||
} else {
|
|
||||||
if(!is_array($columns)) $columns = array($columns);
|
|
||||||
foreach($columns as $key => $val) {
|
|
||||||
$name = $val->attrs->name;
|
|
||||||
/*
|
|
||||||
if(strpos('.',$name)===false && count($output->tables)==1) {
|
|
||||||
$tmp = array_values($output->tables);
|
|
||||||
$name = sprintf('%s.%s', $tmp[0], $val->attrs->name);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
$output->columns[] = array(
|
|
||||||
"name" => $name,
|
|
||||||
"var" => $val->attrs->var,
|
|
||||||
"default" => $val->attrs->default,
|
|
||||||
"notnull" => $val->attrs->notnull,
|
|
||||||
"filter" => $val->attrs->filter,
|
|
||||||
"minlength" => $val->attrs->minlength,
|
|
||||||
"maxlength" => $val->attrs->maxlength,
|
|
||||||
"alias" => $val->attrs->alias,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 조건절 정리
|
|
||||||
$conditions = $xml_obj->query->conditions;
|
$conditions = $xml_obj->query->conditions;
|
||||||
|
$out = $this->_setConditions($conditions);
|
||||||
|
$output->conditions = $out->conditions;
|
||||||
|
|
||||||
$condition = $conditions->condition;
|
foreach($output->left_tables as $key => $val){
|
||||||
if($condition) {
|
if($left_conditions[$key]){
|
||||||
$obj->condition = $condition;
|
$out = $this->_setConditions($left_conditions[$key]);
|
||||||
unset($condition);
|
$output->left_conditions[$key] = $out->conditions;
|
||||||
$condition = array($obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
$condition_group = $conditions->group;
|
|
||||||
if($condition_group && !is_array($condition_group)) $condition_group = array($condition_group);
|
|
||||||
|
|
||||||
if($condition && $condition_group) $cond = array_merge($condition, $condition_group);
|
|
||||||
elseif($condition_group) $cond = $condition_group;
|
|
||||||
else $cond = $condition;
|
|
||||||
|
|
||||||
if($cond) {
|
|
||||||
foreach($cond as $key => $val) {
|
|
||||||
unset($cond_output);
|
|
||||||
|
|
||||||
if($val->attrs->pipe) $cond_output->pipe = $val->attrs->pipe;
|
|
||||||
else $cond_output->pipe = null;
|
|
||||||
|
|
||||||
if(!$val->condition) continue;
|
|
||||||
if(!is_array($val->condition)) $val->condition = array($val->condition);
|
|
||||||
|
|
||||||
foreach($val->condition as $k => $v) {
|
|
||||||
$obj = $v->attrs;
|
|
||||||
if(!$obj->alias) $obj->alias = $obj->column;
|
|
||||||
$cond_output->condition[] = $obj;
|
|
||||||
}
|
|
||||||
|
|
||||||
$output->conditions[] = $cond_output;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// group 정리
|
|
||||||
$group_list = $xml_obj->query->groups->group;
|
$group_list = $xml_obj->query->groups->group;
|
||||||
if($group_list) {
|
$out = $this->_setGroup($group_list);
|
||||||
if(!is_array($group_list)) $group_list = array($group_list);
|
$output->groups = $out->groups;
|
||||||
for($i=0;$i<count($group_list);$i++) {
|
|
||||||
$group = $group_list[$i];
|
|
||||||
$column = trim($group->attrs->column);
|
|
||||||
if(!$column) continue;
|
|
||||||
$group_column_list[] = $column;
|
|
||||||
}
|
|
||||||
if(count($group_column_list)) $output->groups = $group_column_list;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 네비게이션 정리
|
// 네비게이션 정리
|
||||||
$navigation = $xml_obj->query->navigation;
|
$out = $this->_setNavigation($xml_obj);
|
||||||
if($navigation) {
|
$output->order = $out->order;
|
||||||
$order = $navigation->index;
|
$output->list_count = $out->list_count;
|
||||||
if($order) {
|
$output->page_count = $out->page_count;
|
||||||
if(!is_array($order)) $order = array($order);
|
$output->page = $out->page;
|
||||||
foreach($order as $order_info) {
|
|
||||||
$output->order[] = $order_info->attrs;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$list_count = $navigation->list_count->attrs;
|
|
||||||
$output->list_count = $list_count;
|
|
||||||
|
|
||||||
$page_count = $navigation->page_count->attrs;
|
|
||||||
$output->page_count = $page_count;
|
|
||||||
|
|
||||||
$page = $navigation->page->attrs;
|
|
||||||
$output->page = $page ;
|
|
||||||
}
|
|
||||||
|
|
||||||
$column_count = count($output->columns);
|
$column_count = count($output->columns);
|
||||||
$condition_count = count($output->conditions);
|
$condition_count = count($output->conditions);
|
||||||
|
|
||||||
// php script 생성
|
|
||||||
|
|
||||||
// table 정리
|
|
||||||
$buff .= '$output->tables = array( ';
|
$buff .= '$output->tables = array( ';
|
||||||
|
foreach($output->tables as $key => $val) {
|
||||||
|
if(!array_key_exists($key,$output->left_tables)){
|
||||||
|
$buff .= sprintf('"%s"=>"%s",', $key, $val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$buff .= ' );'."\n";
|
||||||
|
|
||||||
|
|
||||||
|
// php script 생성
|
||||||
|
$buff .= '$output->_tables = array( ';
|
||||||
foreach($output->tables as $key => $val) {
|
foreach($output->tables as $key => $val) {
|
||||||
$buff .= sprintf('"%s"=>"%s",', $key, $val);
|
$buff .= sprintf('"%s"=>"%s",', $key, $val);
|
||||||
}
|
}
|
||||||
$buff .= ' );'."\n";
|
$buff .= ' );'."\n";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if(count($output->left_tables)){
|
||||||
|
$buff .= '$output->left_tables = array( ';
|
||||||
|
foreach($output->left_tables as $key => $val) {
|
||||||
|
$buff .= sprintf('"%s"=>"%s",', $key, $val);
|
||||||
|
}
|
||||||
|
$buff .= ' );'."\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// column 정리
|
// column 정리
|
||||||
if($column_count) {
|
if($column_count) {
|
||||||
$buff .= '$output->columns = array ( ';
|
$buff .= '$output->columns = array ( ';
|
||||||
foreach($output->columns as $key => $val) {
|
$buff .= $this->_getColumn($output->columns);
|
||||||
$val['default'] = $this->getDefault($val['name'], $val['default']);
|
|
||||||
if($val['var'] && strpos($val['var'],'.')===false) {
|
|
||||||
|
|
||||||
if($val['default']) $buff .= sprintf('array("name"=>"%s", "alias"=>"%s", "value"=>$args->%s?$args->%s:%s),%s', $val['name'], $val['alias'], $val['var'], $val['var'], $val['default'] ,"\n");
|
|
||||||
else $buff .= sprintf('array("name"=>"%s", "alias"=>"%s", "value"=>$args->%s),%s', $val['name'], $val['alias'], $val['var'], "\n");
|
|
||||||
|
|
||||||
if($val['default']) $default_list[$val['var']] = $val['default'];
|
|
||||||
if($val['notnull']) $notnull_list[] = $val['var'];
|
|
||||||
if($val['minlength']) $minlength_list[$val['var']] = $val['minlength'];
|
|
||||||
if($val['maxlength']) $maxlength_list[$val['var']] = $val['maxlength'];
|
|
||||||
} else {
|
|
||||||
if($val['default']) $buff .= sprintf('array("name"=>"%s", "alias"=>"%s", "value"=>%s),%s', $val['name'], $val['alias'], $val['default'] ,"\n");
|
|
||||||
else $buff .= sprintf('array("name"=>"%s", "alias"=>"%s",),%s', $val['name'], $val['alias'], "\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$buff .= ' );'."\n";
|
$buff .= ' );'."\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
// conditions 정리
|
// conditions 정리
|
||||||
if($condition_count) {
|
if($condition_count) {
|
||||||
$buff .= '$output->conditions = array ( ';
|
$buff .= '$output->conditions = array ( ';
|
||||||
foreach($output->conditions as $key => $val) {
|
$buff .= $this->_getConditions($output->conditions);
|
||||||
$buff .= sprintf('array("pipe"=>"%s",%s"condition"=>array(', $val->pipe,"\n");
|
|
||||||
foreach($val->condition as $k => $v) {
|
|
||||||
$v->default = $this->getDefault($v->column, $v->default);
|
|
||||||
if($v->var) {
|
|
||||||
if(strpos($v->var,".")===false) {
|
|
||||||
if($v->default) $default_list[$v->var] = $v->default;
|
|
||||||
if($v->filter) $filter_list[] = $v;
|
|
||||||
if($v->notnull) $notnull_list[] = $v->var;
|
|
||||||
if($v->default) $buff .= sprintf('array("column"=>"%s", "value"=>$args->%s?$args->%s:%s,"pipe"=>"%s","operation"=>"%s",),%s', $v->column, $v->var, $v->var, $v->default, $v->pipe, $v->operation, "\n");
|
|
||||||
else $buff .= sprintf('array("column"=>"%s", "value"=>$args->%s,"pipe"=>"%s","operation"=>"%s",),%s', $v->column, $v->var, $v->pipe, $v->operation, "\n");
|
|
||||||
} else {
|
|
||||||
$buff .= sprintf('array("column"=>"%s", "value"=>"%s","pipe"=>"%s","operation"=>"%s",),%s', $v->column, $v->var, $v->pipe, $v->operation, "\n");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if($v->default) $buff .= sprintf('array("column"=>"%s", "value"=>%s,"pipe"=>"%s","operation"=>"%s",),%s', $v->column, $v->default ,$v->pipe, $v->operation,"\n");
|
|
||||||
else $buff .= sprintf('array("column"=>"%s", "pipe"=>"%s","operation"=>"%s",),%s', $v->column, $v->pipe, $v->operation,"\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$buff .= ')),'."\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
$buff .= ' );'."\n";
|
$buff .= ' );'."\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// conditions 정리
|
||||||
|
if(count($output->left_conditions)) {
|
||||||
|
$buff .= '$output->left_conditions = array ( ';
|
||||||
|
foreach($output->left_conditions as $key => $val){
|
||||||
|
$buff .= "'{$key}' => array ( ";
|
||||||
|
$buff .= $this->_getConditions($val);
|
||||||
|
$buff .= "),\n";
|
||||||
|
}
|
||||||
|
$buff .= ' );'."\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// order 정리
|
// order 정리
|
||||||
if($output->order) {
|
if($output->order) {
|
||||||
$buff .= '$output->order = array(';
|
$buff .= '$output->order = array(';
|
||||||
|
|
@ -312,6 +247,179 @@
|
||||||
FileHandler::writeFile($cache_file, $buff);
|
FileHandler::writeFile($cache_file, $buff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function _setColumn($columns){
|
||||||
|
|
||||||
|
if(!$columns) {
|
||||||
|
$output->column[] = array("*" => "*");
|
||||||
|
} else {
|
||||||
|
if(!is_array($columns)) $columns = array($columns);
|
||||||
|
foreach($columns as $key => $val) {
|
||||||
|
$name = $val->attrs->name;
|
||||||
|
/*
|
||||||
|
if(strpos('.',$name)===false && count($output->tables)==1) {
|
||||||
|
$tmp = array_values($output->tables);
|
||||||
|
$name = sprintf('%s.%s', $tmp[0], $val->attrs->name);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
$output->columns[] = array(
|
||||||
|
"name" => $name,
|
||||||
|
"var" => $val->attrs->var,
|
||||||
|
"default" => $val->attrs->default,
|
||||||
|
"notnull" => $val->attrs->notnull,
|
||||||
|
"filter" => $val->attrs->filter,
|
||||||
|
"minlength" => $val->attrs->minlength,
|
||||||
|
"maxlength" => $val->attrs->maxlength,
|
||||||
|
"alias" => $val->attrs->alias,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function _setConditions($conditions){
|
||||||
|
// 조건절 정리
|
||||||
|
|
||||||
|
$condition = $conditions->condition;
|
||||||
|
if($condition) {
|
||||||
|
$obj->condition = $condition;
|
||||||
|
unset($condition);
|
||||||
|
$condition = array($obj);
|
||||||
|
}
|
||||||
|
$condition_group = $conditions->group;
|
||||||
|
if($condition_group && !is_array($condition_group)) $condition_group = array($condition_group);
|
||||||
|
|
||||||
|
if($condition && $condition_group) $cond = array_merge($condition, $condition_group);
|
||||||
|
elseif($condition_group) $cond = $condition_group;
|
||||||
|
else $cond = $condition;
|
||||||
|
|
||||||
|
if($cond) {
|
||||||
|
foreach($cond as $key => $val) {
|
||||||
|
unset($cond_output);
|
||||||
|
|
||||||
|
if($val->attrs->pipe) $cond_output->pipe = $val->attrs->pipe;
|
||||||
|
else $cond_output->pipe = null;
|
||||||
|
|
||||||
|
if(!$val->condition) continue;
|
||||||
|
if(!is_array($val->condition)) $val->condition = array($val->condition);
|
||||||
|
|
||||||
|
foreach($val->condition as $k => $v) {
|
||||||
|
$obj = $v->attrs;
|
||||||
|
if(!$obj->alias) $obj->alias = $obj->column;
|
||||||
|
$cond_output->condition[] = $obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
$output->conditions[] = $cond_output;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
function _setGroup($group_list){
|
||||||
|
// group 정리
|
||||||
|
|
||||||
|
if($group_list) {
|
||||||
|
if(!is_array($group_list)) $group_list = array($group_list);
|
||||||
|
for($i=0;$i<count($group_list);$i++) {
|
||||||
|
$group = $group_list[$i];
|
||||||
|
$column = trim($group->attrs->column);
|
||||||
|
if(!$column) continue;
|
||||||
|
$group_column_list[] = $column;
|
||||||
|
}
|
||||||
|
if(count($group_column_list)) $output->groups = $group_column_list;
|
||||||
|
}
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function _setNavigation($xml_obj){
|
||||||
|
$navigation = $xml_obj->query->navigation;
|
||||||
|
if($navigation) {
|
||||||
|
$order = $navigation->index;
|
||||||
|
if($order) {
|
||||||
|
if(!is_array($order)) $order = array($order);
|
||||||
|
foreach($order as $order_info) {
|
||||||
|
$output->order[] = $order_info->attrs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$list_count = $navigation->list_count->attrs;
|
||||||
|
$output->list_count = $list_count;
|
||||||
|
|
||||||
|
$page_count = $navigation->page_count->attrs;
|
||||||
|
$output->page_count = $page_count;
|
||||||
|
|
||||||
|
$page = $navigation->page->attrs;
|
||||||
|
$output->page = $page ;
|
||||||
|
}
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function _getColumn($columns){
|
||||||
|
$buff = '';
|
||||||
|
foreach($columns as $key => $val) {
|
||||||
|
$val['default'] = $this->getDefault($val['name'], $val['default']);
|
||||||
|
if($val['var'] && strpos($val['var'],'.')===false) {
|
||||||
|
|
||||||
|
if($val['default']) $buff .= sprintf('array("name"=>"%s", "alias"=>"%s", "value"=>$args->%s?$args->%s:%s),%s', $val['name'], $val['alias'], $val['var'], $val['var'], $val['default'] ,"\n");
|
||||||
|
else $buff .= sprintf('array("name"=>"%s", "alias"=>"%s", "value"=>$args->%s),%s', $val['name'], $val['alias'], $val['var'], "\n");
|
||||||
|
|
||||||
|
if($val['default']) $default_list[$val['var']] = $val['default'];
|
||||||
|
if($val['notnull']) $notnull_list[] = $val['var'];
|
||||||
|
if($val['minlength']) $minlength_list[$val['var']] = $val['minlength'];
|
||||||
|
if($val['maxlength']) $maxlength_list[$val['var']] = $val['maxlength'];
|
||||||
|
} else {
|
||||||
|
if($val['default']) $buff .= sprintf('array("name"=>"%s", "alias"=>"%s", "value"=>%s),%s', $val['name'], $val['alias'], $val['default'] ,"\n");
|
||||||
|
else $buff .= sprintf('array("name"=>"%s", "alias"=>"%s",),%s', $val['name'], $val['alias'], "\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $buff;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function _getConditions($conditions){
|
||||||
|
$buff = '';
|
||||||
|
foreach($conditions as $key => $val) {
|
||||||
|
$buff .= sprintf('array("pipe"=>"%s",%s"condition"=>array(', $val->pipe,"\n");
|
||||||
|
foreach($val->condition as $k => $v) {
|
||||||
|
$v->default = $this->getDefault($v->column, $v->default);
|
||||||
|
if($v->var) {
|
||||||
|
if(strpos($v->var,".")===false) {
|
||||||
|
if($v->default) $default_list[$v->var] = $v->default;
|
||||||
|
if($v->filter) $filter_list[] = $v;
|
||||||
|
if($v->notnull) $notnull_list[] = $v->var;
|
||||||
|
if($v->default) $buff .= sprintf('array("column"=>"%s", "value"=>$args->%s?$args->%s:%s,"pipe"=>"%s","operation"=>"%s",),%s', $v->column, $v->var, $v->var, $v->default, $v->pipe, $v->operation, "\n");
|
||||||
|
else $buff .= sprintf('array("column"=>"%s", "value"=>$args->%s,"pipe"=>"%s","operation"=>"%s",),%s', $v->column, $v->var, $v->pipe, $v->operation, "\n");
|
||||||
|
} else {
|
||||||
|
$buff .= sprintf('array("column"=>"%s", "value"=>"%s","pipe"=>"%s","operation"=>"%s",),%s', $v->column, $v->var, $v->pipe, $v->operation, "\n");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if($v->default) $buff .= sprintf('array("column"=>"%s", "value"=>%s,"pipe"=>"%s","operation"=>"%s",),%s', $v->column, $v->default ,$v->pipe, $v->operation,"\n");
|
||||||
|
else $buff .= sprintf('array("column"=>"%s", "pipe"=>"%s","operation"=>"%s",),%s', $v->column, $v->pipe, $v->operation,"\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$buff .= ')),'."\n";
|
||||||
|
}
|
||||||
|
return $buff;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief column, condition등의 key에 default 값을 세팅
|
* @brief column, condition등의 key에 default 값을 세팅
|
||||||
**/
|
**/
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue