들여쓰기 수정

git-svn-id: http://xe-core.googlecode.com/svn/sandbox@8066 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
bnu 2011-01-28 02:57:20 +00:00
parent 897cc9802d
commit 0c88d939c0

View file

@ -6,11 +6,11 @@
* @version 0.1p1 * @version 0.1p1
* *
* CUBRID2008 R1.3 대응하도록 수정 Prototype (prototype@cubrid.com) / 09.02.23 * CUBRID2008 R1.3 대응하도록 수정 Prototype (prototype@cubrid.com) / 09.02.23
* 7.3 ~ 2008 R1.3 까지 테스트 완료함. * 7.3 ~ 2008 R1.3 까지 테스트 완료함.
* 기본 쿼리만 사용하였기에 특화된 튜닝이 필요 * 기본 쿼리만 사용하였기에 특화된 튜닝이 필요
**/ **/
class DBCubrid extends DB class DBCubrid extends DB
{ {
/** /**
@ -46,7 +46,7 @@
/** /**
* @brief constructor * @brief constructor
**/ **/
function DBCubrid() function DBCubrid()
{ {
$this->_setDBInfo(); $this->_setDBInfo();
$this->_connect(); $this->_connect();
@ -55,7 +55,7 @@
/** /**
* @brief 설치 가능 여부를 return * @brief 설치 가능 여부를 return
**/ **/
function isSupported() function isSupported()
{ {
if (!function_exists('cubrid_connect')) return false; if (!function_exists('cubrid_connect')) return false;
return true; return true;
@ -64,7 +64,7 @@
/** /**
* @brief DB정보 설정 connect/ close * @brief DB정보 설정 connect/ close
**/ **/
function _setDBInfo() function _setDBInfo()
{ {
$db_info = Context::getDBInfo(); $db_info = Context::getDBInfo();
$this->hostname = $db_info->db_hostname; $this->hostname = $db_info->db_hostname;
@ -101,7 +101,7 @@
/** /**
* @brief DB접속 해제 * @brief DB접속 해제
**/ **/
function close() function close()
{ {
if (!$this->isConnected ()) return; if (!$this->isConnected ()) return;
@ -113,12 +113,12 @@
/** /**
* @brief 쿼리에서 입력되는 문자열 변수들의 quotation 조절 * @brief 쿼리에서 입력되는 문자열 변수들의 quotation 조절
**/ **/
function addQuotes($string) function addQuotes($string)
{ {
if (!$this->fd) return $string; if (!$this->fd) return $string;
if (version_compare (PHP_VERSION, "5.9.0", "<") && if (version_compare (PHP_VERSION, "5.9.0", "<") &&
get_magic_quotes_gpc ()) { get_magic_quotes_gpc ()) {
$string = stripslashes (str_replace ("\\","\\\\", $string)); $string = stripslashes (str_replace ("\\","\\\\", $string));
} }
@ -141,7 +141,7 @@
/** /**
* @brief 트랜잭션 시작 * @brief 트랜잭션 시작
**/ **/
function begin() function begin()
{ {
if (!$this->isConnected () || $this->transaction_started) return; if (!$this->isConnected () || $this->transaction_started) return;
$this->transaction_started = true; $this->transaction_started = true;
@ -150,7 +150,7 @@
/** /**
* @brief 롤백 * @brief 롤백
**/ **/
function rollback() function rollback()
{ {
if (!$this->isConnected () || !$this->transaction_started) return; if (!$this->isConnected () || !$this->transaction_started) return;
@cubrid_rollback ($this->fd); @cubrid_rollback ($this->fd);
@ -160,7 +160,7 @@
/** /**
* @brief 커밋 * @brief 커밋
**/ **/
function commit() function commit()
{ {
if (!$force && (!$this->isConnected () || if (!$force && (!$this->isConnected () ||
!$this->transaction_started)) return; !$this->transaction_started)) return;
@ -178,7 +178,7 @@
* row이면 object\n * row이면 object\n
* return\n * return\n
**/ **/
function _query($query) function _query($query)
{ {
if (!$query || !$this->isConnected ()) return; if (!$query || !$this->isConnected ()) return;
@ -205,7 +205,7 @@
/** /**
* @brief 결과를 fetch * @brief 결과를 fetch
**/ **/
function _fetch($result) function _fetch($result)
{ {
if (!$this->isConnected() || $this->isError() || !$result) return; if (!$this->isConnected() || $this->isError() || !$result) return;
@ -240,7 +240,7 @@
/** /**
* @brief 1 증가되는 sequence 값을 return (cubrid의 auto_increment는 sequence테이블에서만 사용) * @brief 1 증가되는 sequence 값을 return (cubrid의 auto_increment는 sequence테이블에서만 사용)
**/ **/
function getNextSequence() function getNextSequence()
{ {
$this->_makeSequence(); $this->_makeSequence();
@ -252,7 +252,7 @@
} }
/** /**
* @brief 마이그레이션시 sequence 없을 경우 생성 * @brief 마이그레이션시 sequence 없을 경우 생성
**/ **/
function _makeSequence() function _makeSequence()
{ {
@ -278,7 +278,7 @@
$output = $this->_fetch($result); $output = $this->_fetch($result);
$srl = $output->srl; $srl = $output->srl;
if ($srl < 1) { if ($srl < 1) {
$start = 1; $start = 1;
} }
else { else {
$start = $srl + 1000000; $start = $srl + 1000000;
@ -296,7 +296,7 @@
/** /**
* @brief 테이블 기생성 여부 return * @brief 테이블 기생성 여부 return
**/ **/
function isTableExists ($target_name) function isTableExists ($target_name)
{ {
if($target_name == 'sequence') { if($target_name == 'sequence') {
$query = sprintf ("select \"name\" from \"db_serial\" where \"name\" = '%s%s'", $this->prefix, $target_name); $query = sprintf ("select \"name\" from \"db_serial\" where \"name\" = '%s%s'", $this->prefix, $target_name);
@ -321,7 +321,7 @@
/** /**
* @brief 특정 테이블에 특정 column 추가 * @brief 특정 테이블에 특정 column 추가
**/ **/
function addColumn($table_name, $column_name, $type = 'number', $size = '', $default = '', $notnull = false) function addColumn($table_name, $column_name, $type = 'number', $size = '', $default = '', $notnull = false)
{ {
$type = strtoupper($this->column_type[$type]); $type = strtoupper($this->column_type[$type]);
if ($type == 'INTEGER') $size = ''; if ($type == 'INTEGER') $size = '';
@ -356,7 +356,7 @@
/** /**
* @brief 특정 테이블에 특정 column 제거 * @brief 특정 테이블에 특정 column 제거
**/ **/
function dropColumn ($table_name, $column_name) function dropColumn ($table_name, $column_name)
{ {
$query = sprintf ("alter class \"%s%s\" drop \"%s\" ", $this->prefix, $table_name, $column_name); $query = sprintf ("alter class \"%s%s\" drop \"%s\" ", $this->prefix, $table_name, $column_name);
@ -366,7 +366,7 @@
/** /**
* @brief 특정 테이블의 column의 정보를 return * @brief 특정 테이블의 column의 정보를 return
**/ **/
function isColumnExists ($table_name, $column_name) function isColumnExists ($table_name, $column_name)
{ {
$query = sprintf ("select \"attr_name\" from \"db_attribute\" where ". "\"attr_name\" ='%s' and \"class_name\" = '%s%s'", $column_name, $this->prefix, $table_name); $query = sprintf ("select \"attr_name\" from \"db_attribute\" where ". "\"attr_name\" ='%s' and \"class_name\" = '%s%s'", $column_name, $this->prefix, $table_name);
$result = $this->_query ($query); $result = $this->_query ($query);
@ -384,7 +384,7 @@
* $target_columns = array(col1, col2) * $target_columns = array(col1, col2)
* $is_unique? unique : none * $is_unique? unique : none
**/ **/
function addIndex ($table_name, $index_name, $target_columns, $is_unique = false) function addIndex ($table_name, $index_name, $target_columns, $is_unique = false)
{ {
if (!is_array ($target_columns)) { if (!is_array ($target_columns)) {
$target_columns = array ($target_columns); $target_columns = array ($target_columns);
@ -398,7 +398,7 @@
/** /**
* @brief 특정 테이블의 특정 인덱스 삭제 * @brief 특정 테이블의 특정 인덱스 삭제
**/ **/
function dropIndex ($table_name, $index_name, $is_unique = false) function dropIndex ($table_name, $index_name, $is_unique = false)
{ {
$query = sprintf ("drop %s index \"%s\" on \"%s%s\"", $is_unique?'unique':'', $this->prefix .$index_name, $this->prefix, $table_name); $query = sprintf ("drop %s index \"%s\" on \"%s%s\"", $is_unique?'unique':'', $this->prefix .$index_name, $this->prefix, $table_name);
@ -408,7 +408,7 @@
/** /**
* @brief 특정 테이블의 index 정보를 return * @brief 특정 테이블의 index 정보를 return
**/ **/
function isIndexExists ($table_name, $index_name) function isIndexExists ($table_name, $index_name)
{ {
$query = sprintf ("select \"index_name\" from \"db_index\" where ". "\"class_name\" = '%s%s' and \"index_name\" = '%s' ", $this->prefix, $table_name, $this->prefix .$index_name); $query = sprintf ("select \"index_name\" from \"db_index\" where ". "\"class_name\" = '%s%s' and \"index_name\" = '%s' ", $this->prefix, $table_name, $this->prefix .$index_name);
$result = $this->_query ($query); $result = $this->_query ($query);
@ -424,7 +424,7 @@
/** /**
* @brief xml 받아서 테이블을 생성 * @brief xml 받아서 테이블을 생성
**/ **/
function createTableByXml ($xml_doc) function createTableByXml ($xml_doc)
{ {
return $this->_createTable ($xml_doc); return $this->_createTable ($xml_doc);
} }
@ -432,7 +432,7 @@
/** /**
* @brief xml 받아서 테이블을 생성 * @brief xml 받아서 테이블을 생성
**/ **/
function createTableByXmlFile ($file_name) function createTableByXmlFile ($file_name)
{ {
if (!file_exists ($file_name)) return; if (!file_exists ($file_name)) return;
// xml 파일을 읽음 // xml 파일을 읽음
@ -555,7 +555,7 @@
/** /**
* @brief 조건문 작성하여 return * @brief 조건문 작성하여 return
**/ **/
function getCondition ($output) function getCondition ($output)
{ {
if (!$output->conditions) return; if (!$output->conditions) return;
$condition = $this->_getCondition ($output->conditions, $output->column_type, &$output); $condition = $this->_getCondition ($output->conditions, $output->column_type, &$output);
@ -564,7 +564,7 @@
return $condition; return $condition;
} }
function _getCondition ($conditions, $column_type, &$output) function _getCondition ($conditions, $column_type, &$output)
{ {
$condition = ''; $condition = '';
@ -585,7 +585,7 @@
if (!$value) { if (!$value) {
$value = $v['value']; $value = $v['value'];
if (strpos ($value, '(')) { if (strpos ($value, '(')) {
$valuetmp = $value; $valuetmp = $value;
} }
elseif (strpos ($value, ".") === false) { elseif (strpos ($value, ".") === false) {
@ -594,7 +594,7 @@
else { else {
$valuetmp = '"'.str_replace('.', '"."', $value).'"'; $valuetmp = '"'.str_replace('.', '"."', $value).'"';
} }
} }
else { else {
$tmp = explode('.',$value); $tmp = explode('.',$value);
@ -643,7 +643,7 @@
/** /**
* @brief insertAct 처리 * @brief insertAct 처리
**/ **/
function _executeInsertAct ($output) function _executeInsertAct ($output)
{ {
// 테이블 정리 // 테이블 정리
foreach ($output->tables as $val) { foreach ($output->tables as $val) {
@ -654,7 +654,7 @@
foreach ($output->columns as $key => $val) { foreach ($output->columns as $key => $val) {
$name = $val['name']; $name = $val['name'];
$value = $val['value']; $value = $val['value'];
//if ($this->getColumnType ($output->column_type, $name) != 'number') //if ($this->getColumnType ($output->column_type, $name) != 'number')
if ($output->column_type[$name] != 'number') { if ($output->column_type[$name] != 'number') {
if (!is_null($value)) { if (!is_null($value)) {
$value = "'" . $this->addQuotes($value) ."'"; $value = "'" . $this->addQuotes($value) ."'";
@ -691,7 +691,7 @@
/** /**
* @brief updateAct 처리 * @brief updateAct 처리
**/ **/
function _executeUpdateAct ($output) function _executeUpdateAct ($output)
{ {
// 테이블 정리 // 테이블 정리
foreach ($output->tables as $key => $val) { foreach ($output->tables as $key => $val) {
@ -706,7 +706,7 @@
$name = $val['name']; $name = $val['name'];
$value = $val['value']; $value = $val['value'];
if (substr ($value, -2) != '+1' || $output->column_type[$name] != 'number') { if (substr ($value, -2) != '+1' || $output->column_type[$name] != 'number') {
$check_click_count = false; $check_click_count = false;
} }
@ -716,7 +716,7 @@
} }
if ($i < $key) continue; // 중복이 발견되면 이후의 설정은 무시 if ($i < $key) continue; // 중복이 발견되면 이후의 설정은 무시
if (strpos ($name, '.') !== false && strpos ($value, '.') !== false) { if (strpos ($name, '.') !== false && strpos ($value, '.') !== false) {
$column_list[] = $name.' = '.$value; $column_list[] = $name.' = '.$value;
} }
else { else {
@ -748,7 +748,7 @@
$check_click_count_condition = true; $check_click_count_condition = true;
} }
else { else {
if ($v['operation'] == 'in' && !strpos ($v['value'], ',')) { if ($v['operation'] == 'in' && !strpos ($v['value'], ',')) {
$check_click_count_condition = true; $check_click_count_condition = true;
} }
else { else {
@ -764,7 +764,7 @@
} }
} }
if ($check_click_count&& $check_click_count_condition && count ($output->tables) == 1 && count ($output->conditions) > 0 && count ($output->groups) == 0 && count ($output->order) == 0) { if ($check_click_count&& $check_click_count_condition && count ($output->tables) == 1 && count ($output->conditions) > 0 && count ($output->groups) == 0 && count ($output->order) == 0) {
foreach ($output->columns as $v) { foreach ($output->columns as $v) {
$incr_columns[] = 'incr("'.$v['name'].'")'; $incr_columns[] = 'incr("'.$v['name'].'")';
} }
@ -784,7 +784,7 @@
/** /**
* @brief deleteAct 처리 * @brief deleteAct 처리
**/ **/
function _executeDeleteAct ($output) function _executeDeleteAct ($output)
{ {
// 테이블 정리 // 테이블 정리
foreach ($output->tables as $val) { foreach ($output->tables as $val) {
@ -807,7 +807,7 @@
* select의 경우 특정 페이지의 목록을 가져오는 것을 편하게 하기 위해\n * select의 경우 특정 페이지의 목록을 가져오는 것을 편하게 하기 위해\n
* navigation이라는 method를 제공 * navigation이라는 method를 제공
**/ **/
function _executeSelectAct ($output) function _executeSelectAct ($output)
{ {
// 테이블 정리 // 테이블 정리
$table_list = array (); $table_list = array ();
@ -827,92 +827,92 @@
$click_count = array(); $click_count = array();
if(!$output->columns){ if(!$output->columns){
$output->columns = array(array('name'=>'*')); $output->columns = array(array('name'=>'*'));
} }
$column_list = array (); $column_list = array ();
foreach ($output->columns as $key => $val) { foreach ($output->columns as $key => $val) {
$name = $val['name']; $name = $val['name'];
$click_count = '%s'; $click_count = '%s';
if ($val['click_count'] && count ($output->conditions) > 0) { if ($val['click_count'] && count ($output->conditions) > 0) {
$click_count = 'incr(%s)'; $click_count = 'incr(%s)';
} }
$alias = $val['alias'] ? sprintf ('"%s"', $val['alias']) : null; $alias = $val['alias'] ? sprintf ('"%s"', $val['alias']) : null;
$_alias = $val['alias']; $_alias = $val['alias'];
if ($name == '*') { if ($name == '*') {
$column_list[] = $name; $column_list[] = $name;
} }
elseif (strpos ($name, '.') === false && strpos ($name, '(') === false) { elseif (strpos ($name, '.') === false && strpos ($name, '(') === false) {
$name = sprintf ($click_count,$name); $name = sprintf ($click_count,$name);
if ($alias) { if ($alias) {
$column_list[$alias] = sprintf('"%s" as %s', $name, $alias); $column_list[$alias] = sprintf('"%s" as %s', $name, $alias);
} }
else { else {
$column_list[] = sprintf ('"%s"', $name); $column_list[] = sprintf ('"%s"', $name);
} }
} }
else { else {
if (strpos ($name, '.') != false) { if (strpos ($name, '.') != false) {
list ($prefix, $name) = explode('.', $name); list ($prefix, $name) = explode('.', $name);
if (($now_matchs = preg_match_all ("/\(/", $prefix, $xtmp)) > 0) { if (($now_matchs = preg_match_all ("/\(/", $prefix, $xtmp)) > 0) {
if ($now_matchs == 1) { if ($now_matchs == 1) {
$tmpval = explode ("(", $prefix); $tmpval = explode ("(", $prefix);
$tmpval[1] = sprintf ('"%s"', $tmpval[1]); $tmpval[1] = sprintf ('"%s"', $tmpval[1]);
$prefix = implode ("(", $tmpval); $prefix = implode ("(", $tmpval);
$tmpval = explode (")", $name); $tmpval = explode (")", $name);
$tmpval[0] = sprintf ('"%s"', $tmpval[0]); $tmpval[0] = sprintf ('"%s"', $tmpval[0]);
$name = implode (")", $tmpval); $name = implode (")", $tmpval);
} }
} }
else { else {
$prefix = sprintf ('"%s"', $prefix); $prefix = sprintf ('"%s"', $prefix);
$name = ($name == '*') ? $name : sprintf('"%s"',$name); $name = ($name == '*') ? $name : sprintf('"%s"',$name);
} }
$xtmp = null; $xtmp = null;
$now_matchs = null; $now_matchs = null;
if($alias) $column_list[$_alias] = sprintf ($click_count, sprintf ('%s.%s', $prefix, $name)) . ($alias ? sprintf (' as %s',$alias) : ''); if($alias) $column_list[$_alias] = sprintf ($click_count, sprintf ('%s.%s', $prefix, $name)) . ($alias ? sprintf (' as %s',$alias) : '');
else $column_list[] = sprintf ($click_count, sprintf ('%s.%s', $prefix, $name)); else $column_list[] = sprintf ($click_count, sprintf ('%s.%s', $prefix, $name));
} }
elseif (($now_matchs = preg_match_all ("/\(/", $name, $xtmp)) > 0) { elseif (($now_matchs = preg_match_all ("/\(/", $name, $xtmp)) > 0) {
if ($now_matchs == 1 && preg_match ("/[a-zA-Z0-9]*\(\*\)/", $name) < 1) { if ($now_matchs == 1 && preg_match ("/[a-zA-Z0-9]*\(\*\)/", $name) < 1) {
$open_pos = strpos ($name, "("); $open_pos = strpos ($name, "(");
$close_pos = strpos ($name, ")"); $close_pos = strpos ($name, ")");
if (preg_match ("/,/", $name)) { if (preg_match ("/,/", $name)) {
$tmp_func_name = sprintf ('%s', substr ($name, 0, $open_pos)); $tmp_func_name = sprintf ('%s', substr ($name, 0, $open_pos));
$tmp_params = sprintf ('%s', substr ($name, $open_pos + 1, $close_pos - $open_pos - 1)); $tmp_params = sprintf ('%s', substr ($name, $open_pos + 1, $close_pos - $open_pos - 1));
$tmpval = null; $tmpval = null;
$tmpval = explode (',', $tmp_params); $tmpval = explode (',', $tmp_params);
foreach ($tmpval as $tmp_param) { foreach ($tmpval as $tmp_param) {
$tmp_param_list[] = (!is_numeric ($tmp_param)) ? sprintf ('"%s"', $tmp_param) : $tmp_param; $tmp_param_list[] = (!is_numeric ($tmp_param)) ? sprintf ('"%s"', $tmp_param) : $tmp_param;
} }
$tmpval = implode (',', $tmp_param_list); $tmpval = implode (',', $tmp_param_list);
$name = sprintf ('%s(%s)', $tmp_func_name, $tmpval); $name = sprintf ('%s(%s)', $tmp_func_name, $tmpval);
} }
else { else {
$name = sprintf ('%s("%s")', substr ($name, 0, $open_pos), substr ($name, $open_pos + 1, $close_pos - $open_pos - 1)); $name = sprintf ('%s("%s")', substr ($name, 0, $open_pos), substr ($name, $open_pos + 1, $close_pos - $open_pos - 1));
} }
} }
if($alias) $column_list[$_alias] = sprintf ($click_count, $name). ($alias ? sprintf (' as %s', $alias) : ''); if($alias) $column_list[$_alias] = sprintf ($click_count, $name). ($alias ? sprintf (' as %s', $alias) : '');
else $column_list[] = sprintf ($click_count, $name); else $column_list[] = sprintf ($click_count, $name);
} }
else { else {
if($alias) $column_list[$_alias] = sprintf($click_count, $name). ($alias ? sprintf(' as %s',$alias) : ''); if($alias) $column_list[$_alias] = sprintf($click_count, $name). ($alias ? sprintf(' as %s',$alias) : '');
else $column_list[] = sprintf($click_count, $name); else $column_list[] = sprintf($click_count, $name);
} }
} }
$columns = implode (',', $column_list); $columns = implode (',', $column_list);
} }
$condition = $this->getCondition ($output); $condition = $this->getCondition ($output);
$output->column_list = $column_list; $output->column_list = $column_list;
if ($output->list_count && $output->page) { if ($output->list_count && $output->page) {
return ($this->_getNavigationData($table_list, $columns, $left_join, $condition, $output)); return ($this->_getNavigationData($table_list, $columns, $left_join, $condition, $output));
} }
@ -947,10 +947,10 @@
$output->groups[$key] = $value; $output->groups[$key] = $value;
if(count($output->arg_columns)) if(count($output->arg_columns))
{ {
if($column_list[$value]) $output->arg_columns[] = $column_list[$value]; if($column_list[$value]) $output->arg_columns[] = $column_list[$value];
} }
} }
$groupby_query = sprintf ('group by %s', implode(',', $output->groups)); $groupby_query = sprintf ('group by %s', implode(',', $output->groups));
} }
@ -1006,7 +1006,7 @@
else $val[0] = sprintf ('"%s"', $val[0]); else $val[0] = sprintf ('"%s"', $val[0]);
$index_list[] = sprintf('%s %s', $val[0], $val[1]); $index_list[] = sprintf('%s %s', $val[0], $val[1]);
if(count($output->arg_columns) && $column_list[$val]) $output->arg_columns[] = $column_list[$key]; if(count($output->arg_columns) && $column_list[$val]) $output->arg_columns[] = $column_list[$key];
} }
if (count ($index_list)) { if (count ($index_list)) {
@ -1016,16 +1016,16 @@
} }
if(count($output->arg_columns)) if(count($output->arg_columns))
{ {
$columns = array(); $columns = array();
foreach($output->arg_columns as $col){ foreach($output->arg_columns as $col){
if(strpos($col,'"')===false && strpos($col,' ')===false) $columns[] = '"'.$col.'"'; if(strpos($col,'"')===false && strpos($col,' ')===false) $columns[] = '"'.$col.'"';
else $columns[] = $col; else $columns[] = $col;
} }
$columns = join(',',$columns); $columns = join(',',$columns);
} }
$query = sprintf ("select %s from %s %s %s %s", $columns, implode (',',$table_list), implode (' ',$left_join), $condition, $groupby_query.$orderby_query); $query = sprintf ("select %s from %s %s %s %s", $columns, implode (',',$table_list), implode (' ',$left_join), $condition, $groupby_query.$orderby_query);
$query .= (__DEBUG_QUERY__&1 && $output->query_id)?sprintf (' '.$this->comment_syntax, $this->query_id):''; $query .= (__DEBUG_QUERY__&1 && $output->query_id)?sprintf (' '.$this->comment_syntax, $this->query_id):'';
@ -1099,18 +1099,18 @@
function _getNavigationData ($table_list, $columns, $left_join, $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');
$column_list = $output->column_list; $column_list = $output->column_list;
$count_condition = count($output->groups) ? sprintf('%s group by %s', $condition, implode(', ', $output->groups)) : $condition; $count_condition = count($output->groups) ? sprintf('%s group by %s', $condition, implode(', ', $output->groups)) : $condition;
$count_query = sprintf('select count(*) as "count" from %s %s %s', implode(', ', $table_list), implode(' ', $left_join), $count_condition); $count_query = sprintf('select count(*) as "count" from %s %s %s', implode(', ', $table_list), implode(' ', $left_join), $count_condition);
if (count($output->groups)) { if (count($output->groups)) {
$count_query = sprintf('select count(*) as "count" from (%s) xet', $count_query); $count_query = sprintf('select count(*) as "count" from (%s) xet', $count_query);
} }
$count_query .= (__DEBUG_QUERY__&1 && $output->query_id)?sprintf (' '.$this->comment_syntax, $this->query_id):''; $count_query .= (__DEBUG_QUERY__&1 && $output->query_id)?sprintf (' '.$this->comment_syntax, $this->query_id):'';
$result = $this->_query($count_query); $result = $this->_query($count_query);
$count_output = $this->_fetch($result); $count_output = $this->_fetch($result);
$total_count = (int)$count_output->count; $total_count = (int)$count_output->count;
$list_count = $output->list_count['value']; $list_count = $output->list_count['value'];
if (!$list_count) $list_count = 20; if (!$list_count) $list_count = 20;
@ -1194,16 +1194,16 @@
} }
} }
if(count($output->arg_columns)) if(count($output->arg_columns))
{ {
$columns = array(); $columns = array();
foreach($output->arg_columns as $col){ foreach($output->arg_columns as $col){
if(strpos($col,'"')===false) $columns[] = '"'.$col.'"'; if(strpos($col,'"')===false) $columns[] = '"'.$col.'"';
else $columns[] = $col; else $columns[] = $col;
} }
$columns = join(',',$columns); $columns = join(',',$columns);
} }
$query = sprintf ("select %s from %s %s %s %s", $columns, implode (',',$table_list), implode (' ',$left_join), $condition, $groupby_query.$orderby_query); $query = sprintf ("select %s from %s %s %s %s", $columns, implode (',',$table_list), implode (' ',$left_join), $condition, $groupby_query.$orderby_query);
$query .= (__DEBUG_QUERY__&1 && $output->query_id)?sprintf (' '.$this->comment_syntax, $this->query_id):''; $query .= (__DEBUG_QUERY__&1 && $output->query_id)?sprintf (' '.$this->comment_syntax, $this->query_id):'';