mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-10 12:32:14 +09:00
#19259536: DBCubrid class 들여쓰기 및 블록 개행 관련 수정.
git-svn-id: http://xe-core.googlecode.com/svn/sandbox@7833 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
8abedcd27f
commit
65dc12aa6e
1 changed files with 274 additions and 419 deletions
|
|
@ -89,8 +89,7 @@
|
||||||
$this->fd = @cubrid_connect ($this->hostname, $this->port, $this->database, $this->userid, $this->password);
|
$this->fd = @cubrid_connect ($this->hostname, $this->port, $this->database, $this->userid, $this->password);
|
||||||
|
|
||||||
// 접속체크
|
// 접속체크
|
||||||
if (!$this->fd)
|
if (!$this->fd) {
|
||||||
{
|
|
||||||
$this->setError (-1, 'database connect fail');
|
$this->setError (-1, 'database connect fail');
|
||||||
return $this->is_connected = false;
|
return $this->is_connected = false;
|
||||||
}
|
}
|
||||||
|
|
@ -118,20 +117,17 @@
|
||||||
{
|
{
|
||||||
if (!$this->fd) return $string;
|
if (!$this->fd) return $string;
|
||||||
|
|
||||||
if (version_compare (PHP_VERSION, "5.9.0", "<") && get_magic_quotes_gpc ())
|
if (version_compare (PHP_VERSION, "5.9.0", "<") &&
|
||||||
{
|
get_magic_quotes_gpc ()) {
|
||||||
$string = stripslashes (str_replace ("\\","\\\\", $string));
|
$string = stripslashes (str_replace ("\\","\\\\", $string));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_numeric ($string))
|
if (!is_numeric ($string)) {
|
||||||
{
|
|
||||||
/*
|
/*
|
||||||
if ($this->isConnected())
|
if ($this->isConnected()) {
|
||||||
{
|
|
||||||
$string = cubrid_real_escape_string($string);
|
$string = cubrid_real_escape_string($string);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
$string = str_replace("'","\'",$string);
|
$string = str_replace("'","\'",$string);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
@ -166,7 +162,8 @@
|
||||||
**/
|
**/
|
||||||
function commit()
|
function commit()
|
||||||
{
|
{
|
||||||
if (!$force && (!$this->isConnected () || !$this->transaction_started)) return;
|
if (!$force && (!$this->isConnected () ||
|
||||||
|
!$this->transaction_started)) return;
|
||||||
|
|
||||||
@cubrid_commit($this->fd);
|
@cubrid_commit($this->fd);
|
||||||
$this->transaction_started = false;
|
$this->transaction_started = false;
|
||||||
|
|
@ -218,20 +215,15 @@
|
||||||
$col_names = cubrid_column_names ($result);
|
$col_names = cubrid_column_names ($result);
|
||||||
$max = count ($col_types);
|
$max = count ($col_types);
|
||||||
|
|
||||||
for ($count = 0; $count < $max; $count++)
|
for ($count = 0; $count < $max; $count++) {
|
||||||
{
|
if (preg_match ("/^char/", $col_types[$count]) > 0) {
|
||||||
if (preg_match ("/^char/", $col_types[$count]) > 0)
|
|
||||||
{
|
|
||||||
$char_type_fields[] = $col_names[$count];
|
$char_type_fields[] = $col_names[$count];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while ($tmp = cubrid_fetch ($result, CUBRID_OBJECT))
|
while ($tmp = cubrid_fetch ($result, CUBRID_OBJECT)) {
|
||||||
{
|
if (is_array ($char_type_fields)) {
|
||||||
if (is_array ($char_type_fields))
|
foreach ($char_type_fields as $val) {
|
||||||
{
|
|
||||||
foreach ($char_type_fields as $val)
|
|
||||||
{
|
|
||||||
$tmp->{$val} = rtrim ($tmp->{$val});
|
$tmp->{$val} = rtrim ($tmp->{$val});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -274,25 +266,23 @@
|
||||||
$output = $this->_fetch($result);
|
$output = $this->_fetch($result);
|
||||||
|
|
||||||
// if do not create serial
|
// if do not create serial
|
||||||
if($output->count==0)
|
if ($output->count==0) {
|
||||||
{
|
$query = sprintf('select max("a"."srl") as "srl" from '.
|
||||||
$query = sprintf('select max(a.srl) as srl from
|
'( select max("document_srl") as "srl" from '.
|
||||||
( select max(document_srl) as srl from %sdocuments
|
'"%sdocuments" UNION '.
|
||||||
UNION
|
'select max("comment_srl") as "srl" from '.
|
||||||
select max(comment_srl) as srl from %scomments
|
'"%scomments" UNION '.
|
||||||
UNION
|
'select max("member_srl") as "srl" from '.
|
||||||
select max(member_srl) as srl from %smember
|
'"%smember"'.
|
||||||
) as "a"',$this->prefix,$this->prefix,$this->prefix);
|
') as "a"', $this->prefix, $this->prefix, $this->prefix);
|
||||||
|
|
||||||
$result = $this->_query($query);
|
$result = $this->_query($query);
|
||||||
$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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -310,23 +300,19 @@
|
||||||
**/
|
**/
|
||||||
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);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
$query = sprintf ("select \"class_name\" from \"db_class\" where \"class_name\" = '%s%s'", $this->prefix, $target_name);
|
$query = sprintf ("select \"class_name\" from \"db_class\" where \"class_name\" = '%s%s'", $this->prefix, $target_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->_query ($query);
|
$result = $this->_query ($query);
|
||||||
//if(!$result) debugPrint($query);
|
//if(!$result) debugPrint($query);
|
||||||
if (cubrid_num_rows($result) > 0)
|
if (cubrid_num_rows($result) > 0) {
|
||||||
{
|
|
||||||
$output = true;
|
$output = true;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
$output = false;
|
$output = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -345,28 +331,22 @@
|
||||||
|
|
||||||
$query = sprintf ("alter class \"%s%s\" add \"%s\" ", $this->prefix, $table_name, $column_name);
|
$query = sprintf ("alter class \"%s%s\" add \"%s\" ", $this->prefix, $table_name, $column_name);
|
||||||
|
|
||||||
if ($type == 'char' || $type == 'varchar')
|
if ($type == 'char' || $type == 'varchar') {
|
||||||
{
|
|
||||||
if ($size) $size = $size * 3;
|
if ($size) $size = $size * 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($size)
|
if ($size) {
|
||||||
{
|
|
||||||
$query .= sprintf ("%s(%s) ", $type, $size);
|
$query .= sprintf ("%s(%s) ", $type, $size);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
$query .= sprintf ("%s ", $type);
|
$query .= sprintf ("%s ", $type);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($default)
|
if ($default) {
|
||||||
{
|
if ($type == 'INTEGER' || $type == 'BIGINT' || $type=='INT') {
|
||||||
if ($type == 'INTEGER' || $type == 'BIGINT' || $type=='INT')
|
|
||||||
{
|
|
||||||
$query .= sprintf ("default %d ", $default);
|
$query .= sprintf ("default %d ", $default);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
$query .= sprintf ("default '%s' ", $default);
|
$query .= sprintf ("default '%s' ", $default);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -409,8 +389,7 @@
|
||||||
**/
|
**/
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -482,9 +461,10 @@
|
||||||
$table_name = $xml_obj->table->attrs->name;
|
$table_name = $xml_obj->table->attrs->name;
|
||||||
|
|
||||||
// 만약 테이블 이름이 sequence라면 serial 생성
|
// 만약 테이블 이름이 sequence라면 serial 생성
|
||||||
if ($table_name == 'sequence')
|
if ($table_name == 'sequence') {
|
||||||
{
|
$query = sprintf ('create serial "%s" start with 1 increment by 1'.
|
||||||
$query = sprintf ('create serial "%s" start with 1 increment by '. '1 minvalue 1 maxvalue 10000000000000000000000000000000000000'. ' nocycle;', $this->prefix.$table_name);
|
' minvalue 1 '.
|
||||||
|
'maxvalue 10000000000000000000000000000000000000'. ' nocycle;', $this->prefix.$table_name);
|
||||||
|
|
||||||
return $this->_query($query);
|
return $this->_query($query);
|
||||||
}
|
}
|
||||||
|
|
@ -496,12 +476,10 @@
|
||||||
$query = sprintf ('create class "%s";', $table_name);
|
$query = sprintf ('create class "%s";', $table_name);
|
||||||
$this->_query ($query);
|
$this->_query ($query);
|
||||||
|
|
||||||
if (!is_array ($xml_obj->table->column))
|
if (!is_array ($xml_obj->table->column)) {
|
||||||
{
|
|
||||||
$columns[] = $xml_obj->table->column;
|
$columns[] = $xml_obj->table->column;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
$columns = $xml_obj->table->column;
|
$columns = $xml_obj->table->column;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -517,8 +495,7 @@
|
||||||
$unique = $column->attrs->unique;
|
$unique = $column->attrs->unique;
|
||||||
$default = $column->attrs->default;
|
$default = $column->attrs->default;
|
||||||
|
|
||||||
switch ($this->column_type[$type])
|
switch ($this->column_type[$type]) {
|
||||||
{
|
|
||||||
case 'integer' :
|
case 'integer' :
|
||||||
$size = null;
|
$size = null;
|
||||||
break;
|
break;
|
||||||
|
|
@ -527,13 +504,12 @@
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset ($default) && ($type == 'varchar' || $type == 'char' || $type == 'text' || $type == 'tinytext' || $type == 'bigtext'))
|
if (isset ($default) && ($type == 'varchar' || $type == 'char' ||
|
||||||
{
|
$type == 'text' || $type == 'tinytext' || $type == 'bigtext')) {
|
||||||
$default = sprintf ("'%s'", $default);
|
$default = sprintf ("'%s'", $default);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($type == 'varchar' || $type == 'char')
|
if ($type == 'varchar' || $type == 'char') {
|
||||||
{
|
|
||||||
if($size) $size = $size * 3;
|
if($size) $size = $size * 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -543,19 +519,15 @@
|
||||||
$this->column_type[$type],
|
$this->column_type[$type],
|
||||||
$size?'('.$size.')':'',
|
$size?'('.$size.')':'',
|
||||||
isset($default)?"default ".$default:'',
|
isset($default)?"default ".$default:'',
|
||||||
$notnull?'not null':''
|
$notnull?'not null':'');
|
||||||
);
|
|
||||||
|
|
||||||
if ($primary_key)
|
if ($primary_key) {
|
||||||
{
|
|
||||||
$primary_list[] = $name;
|
$primary_list[] = $name;
|
||||||
}
|
}
|
||||||
else if ($unique)
|
else if ($unique) {
|
||||||
{
|
|
||||||
$unique_list[$unique][] = $name;
|
$unique_list[$unique][] = $name;
|
||||||
}
|
}
|
||||||
else if ($index)
|
else if ($index) {
|
||||||
{
|
|
||||||
$index_list[$index][] = $name;
|
$index_list[$index][] = $name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -563,25 +535,20 @@
|
||||||
$query .= implode (',', $column_schema).';';
|
$query .= implode (',', $column_schema).';';
|
||||||
$this->_query ($query);
|
$this->_query ($query);
|
||||||
|
|
||||||
if (count ($primary_list))
|
if (count ($primary_list)) {
|
||||||
{
|
|
||||||
$query = sprintf ("alter class \"%s\" add attribute constraint ". "\"pkey_%s\" PRIMARY KEY(%s);", $table_name, $table_name, '"'.implode('","',$primary_list).'"');
|
$query = sprintf ("alter class \"%s\" add attribute constraint ". "\"pkey_%s\" PRIMARY KEY(%s);", $table_name, $table_name, '"'.implode('","',$primary_list).'"');
|
||||||
$this->_query ($query);
|
$this->_query ($query);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count ($unique_list))
|
if (count ($unique_list)) {
|
||||||
{
|
foreach ($unique_list as $key => $val) {
|
||||||
foreach ($unique_list as $key => $val)
|
|
||||||
{
|
|
||||||
$query = sprintf ("create unique index \"%s\" on \"%s\" ". "(%s);", $this->prefix .$key, $table_name, '"'.implode('","', $val).'"');
|
$query = sprintf ("create unique index \"%s\" on \"%s\" ". "(%s);", $this->prefix .$key, $table_name, '"'.implode('","', $val).'"');
|
||||||
$this->_query ($query);
|
$this->_query ($query);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count ($index_list))
|
if (count ($index_list)) {
|
||||||
{
|
foreach ($index_list as $key => $val) {
|
||||||
foreach ($index_list as $key => $val)
|
|
||||||
{
|
|
||||||
$query = sprintf ("create index \"%s\" on \"%s\" (%s);", $this->prefix .$key, $table_name, '"'.implode('","',$val).'"');
|
$query = sprintf ("create index \"%s\" on \"%s\" (%s);", $this->prefix .$key, $table_name, '"'.implode('","',$val).'"');
|
||||||
$this->_query ($query);
|
$this->_query ($query);
|
||||||
}
|
}
|
||||||
|
|
@ -604,12 +571,10 @@
|
||||||
{
|
{
|
||||||
$condition = '';
|
$condition = '';
|
||||||
|
|
||||||
foreach ($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;
|
||||||
if ($v['value'] === '') continue;
|
if ($v['value'] === '') continue;
|
||||||
if (!in_array (gettype ($v['value']), array ('string', 'integer', 'double'))) continue;
|
if (!in_array (gettype ($v['value']), array ('string', 'integer', 'double'))) continue;
|
||||||
|
|
@ -619,60 +584,47 @@
|
||||||
$value = $v['value'];
|
$value = $v['value'];
|
||||||
$type = $this->getColumnType ($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, $column_type);
|
||||||
|
|
||||||
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) {
|
||||||
{
|
|
||||||
$valuetmp = $value;
|
$valuetmp = $value;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
$valuetmp = '"'.str_replace('.', '"."', $value).'"';
|
$valuetmp = '"'.str_replace('.', '"."', $value).'"';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
$tmp = explode('.',$value);
|
$tmp = explode('.',$value);
|
||||||
|
|
||||||
if(count($tmp)==2)
|
if (count($tmp)==2) {
|
||||||
{
|
|
||||||
$table = $tmp[0];
|
$table = $tmp[0];
|
||||||
$column = $tmp[1];
|
$column = $tmp[1];
|
||||||
|
|
||||||
if($column_type[$column] && (in_array($table,$output->tables) || array_key_exists($table,$output->tables)))
|
if ($column_type[$column] && (in_array ($table, $output->tables) ||
|
||||||
{
|
array_key_exists($table, $output->tables))) {
|
||||||
$valuetmp = sprintf('"%s"."%s"', $table, $column);
|
$valuetmp = sprintf('"%s"."%s"', $table, $column);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
$valuetmp = $value;
|
$valuetmp = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
$valuetmp = $value;
|
$valuetmp = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (strpos ($name, '(') > 0) {
|
||||||
if (strpos ($name, '(') > 0)
|
|
||||||
{
|
|
||||||
$nametmp = $name;
|
$nametmp = $name;
|
||||||
}
|
}
|
||||||
elseif (strpos ($name, ".") === false)
|
elseif (strpos ($name, ".") === false) {
|
||||||
{
|
|
||||||
$nametmp = '"'.$name.'"';
|
$nametmp = '"'.$name.'"';
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
$nametmp = '"'.str_replace('.', '"."', $name).'"';
|
$nametmp = '"'.str_replace('.', '"."', $name).'"';
|
||||||
}
|
}
|
||||||
$str = $this->getConditionPart ($nametmp, $valuetmp, $operation);
|
$str = $this->getConditionPart ($nametmp, $valuetmp, $operation);
|
||||||
|
|
@ -680,10 +632,8 @@
|
||||||
$sub_condition .= $str;
|
$sub_condition .= $str;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($sub_condition)
|
if ($sub_condition) {
|
||||||
{
|
if ($condition && $val['pipe']) {
|
||||||
if ($condition && $val['pipe'])
|
|
||||||
{
|
|
||||||
$condition .= ' '.$val['pipe'].' ';
|
$condition .= ' '.$val['pipe'].' ';
|
||||||
}
|
}
|
||||||
$condition .= '('.$sub_condition.')';
|
$condition .= '('.$sub_condition.')';
|
||||||
|
|
@ -693,44 +643,36 @@
|
||||||
return $condition;
|
return $condition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief insertAct 처리
|
* @brief insertAct 처리
|
||||||
**/
|
**/
|
||||||
function _executeInsertAct ($output)
|
function _executeInsertAct ($output)
|
||||||
{
|
{
|
||||||
// 테이블 정리
|
// 테이블 정리
|
||||||
foreach ($output->tables as $val)
|
foreach ($output->tables as $val) {
|
||||||
{
|
|
||||||
$table_list[] = '"'.$this->prefix.$val.'"';
|
$table_list[] = '"'.$this->prefix.$val.'"';
|
||||||
}
|
}
|
||||||
|
|
||||||
// 컬럼 정리
|
// 컬럼 정리
|
||||||
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) ."'";
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
if ($val['notnull']=='notnull') {
|
if ($val['notnull']=='notnull') {
|
||||||
$value = "''";
|
$value = "''";
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
//$value = 'null';
|
//$value = 'null';
|
||||||
$value = "''";
|
$value = "''";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif (!$value || is_numeric ($value))
|
elseif (!$value || is_numeric ($value)) {
|
||||||
{
|
|
||||||
$value = (int) $value;
|
$value = (int) $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -742,8 +684,7 @@
|
||||||
|
|
||||||
$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):'';
|
||||||
$result = $this->_query ($query);
|
$result = $this->_query ($query);
|
||||||
if ($result && !$this->transaction_started)
|
if ($result && !$this->transaction_started) {
|
||||||
{
|
|
||||||
@cubrid_commit ($this->fd);
|
@cubrid_commit ($this->fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -756,45 +697,37 @@
|
||||||
function _executeUpdateAct ($output)
|
function _executeUpdateAct ($output)
|
||||||
{
|
{
|
||||||
// 테이블 정리
|
// 테이블 정리
|
||||||
foreach ($output->tables as $key => $val)
|
foreach ($output->tables as $key => $val) {
|
||||||
{
|
|
||||||
$table_list[] = '"'.$this->prefix.$val.'" as "'.$key.'"';
|
$table_list[] = '"'.$this->prefix.$val.'" as "'.$key.'"';
|
||||||
}
|
}
|
||||||
|
|
||||||
$check_click_count = true;
|
$check_click_count = true;
|
||||||
|
|
||||||
// 컬럼 정리
|
// 컬럼 정리
|
||||||
foreach ($output->columns as $key => $val)
|
foreach ($output->columns as $key => $val) {
|
||||||
{
|
|
||||||
if (!isset ($val['value'])) continue;
|
if (!isset ($val['value'])) continue;
|
||||||
$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;
|
||||||
}
|
}
|
||||||
|
|
||||||
for ($i = 0; $i < $key; $i++)
|
for ($i = 0; $i < $key; $i++) {
|
||||||
{
|
|
||||||
/* 한문장에 같은 속성에 대한 중복 설정은 큐브리드에서는 허용치 않음 */
|
/* 한문장에 같은 속성에 대한 중복 설정은 큐브리드에서는 허용치 않음 */
|
||||||
if ($output->columns[$i]['name'] == $name) break;
|
if ($output->columns[$i]['name'] == $name) break;
|
||||||
}
|
}
|
||||||
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 {
|
||||||
{
|
if ($output->column_type[$name] != 'number') {
|
||||||
if ($output->column_type[$name] != 'number')
|
|
||||||
{
|
|
||||||
$check_column = false;
|
$check_column = false;
|
||||||
$value = "'".$this->addQuotes ($value)."'";
|
$value = "'".$this->addQuotes ($value)."'";
|
||||||
}
|
}
|
||||||
elseif (!$value || is_numeric ($value))
|
elseif (!$value || is_numeric ($value)) {
|
||||||
{
|
|
||||||
$value = (int) $value;
|
$value = (int) $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -806,36 +739,27 @@
|
||||||
$condition = $this->getCondition ($output);
|
$condition = $this->getCondition ($output);
|
||||||
|
|
||||||
$check_click_count_condition = false;
|
$check_click_count_condition = false;
|
||||||
if ($check_click_count)
|
if ($check_click_count) {
|
||||||
{
|
foreach ($output->conditions as $val) {
|
||||||
foreach ($output->conditions as $val)
|
if ($val['pipe'] == 'or') {
|
||||||
{
|
|
||||||
if ($val['pipe'] == 'or')
|
|
||||||
{
|
|
||||||
$check_click_count_condition = false;
|
$check_click_count_condition = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($val['condition'] as $v)
|
foreach ($val['condition'] as $v) {
|
||||||
{
|
if ($v['operation'] == 'equal') {
|
||||||
if ($v['operation'] == 'equal')
|
|
||||||
{
|
|
||||||
$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 {
|
||||||
{
|
|
||||||
$check_click_count_condition = false;
|
$check_click_count_condition = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($v['pipe'] == 'or')
|
if ($v['pipe'] == 'or') {
|
||||||
{
|
|
||||||
$check_click_count_condition = false;
|
$check_click_count_condition = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -843,17 +767,14 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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'].'")';
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = sprintf ('select %s from %s %s', join (',', $incr_columns), implode(',', $table_list), $condition);
|
$query = sprintf ('select %s from %s %s', join (',', $incr_columns), implode(',', $table_list), $condition);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
$query = sprintf ("update %s set %s %s", implode (',', $table_list), implode (',', $column_list), $condition);
|
$query = sprintf ("update %s set %s %s", implode (',', $table_list), implode (',', $column_list), $condition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -869,8 +790,7 @@
|
||||||
function _executeDeleteAct ($output)
|
function _executeDeleteAct ($output)
|
||||||
{
|
{
|
||||||
// 테이블 정리
|
// 테이블 정리
|
||||||
foreach ($output->tables as $val)
|
foreach ($output->tables as $val) {
|
||||||
{
|
|
||||||
$table_list[] = '"'.$this->prefix.$val.'"';
|
$table_list[] = '"'.$this->prefix.$val.'"';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -894,8 +814,7 @@
|
||||||
{
|
{
|
||||||
// 테이블 정리
|
// 테이블 정리
|
||||||
$table_list = array ();
|
$table_list = array ();
|
||||||
foreach ($output->tables as $key => $val)
|
foreach ($output->tables as $key => $val) {
|
||||||
{
|
|
||||||
$table_list[] = '"'.$this->prefix.$val.'" as "'.$key.'"';
|
$table_list[] = '"'.$this->prefix.$val.'" as "'.$key.'"';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -903,59 +822,45 @@
|
||||||
// why???
|
// why???
|
||||||
$left_tables = (array) $output->left_tables;
|
$left_tables = (array) $output->left_tables;
|
||||||
|
|
||||||
foreach ($left_tables as $key => $val)
|
foreach ($left_tables as $key => $val) {
|
||||||
{
|
|
||||||
$condition = $this->_getCondition ($output->left_conditions[$key], $output->column_type, &$output);
|
$condition = $this->_getCondition ($output->left_conditions[$key], $output->column_type, &$output);
|
||||||
if ($condition)
|
if ($condition) {
|
||||||
{
|
|
||||||
$left_join[] = $val.' "'.$this->prefix.$output->_tables[$key]. '" "'.$key.'" on ('.$condition.')';
|
$left_join[] = $val.' "'.$this->prefix.$output->_tables[$key]. '" "'.$key.'" on ('.$condition.')';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$output->columns)
|
if (!$output->columns) {
|
||||||
{
|
|
||||||
$columns = '*';
|
$columns = '*';
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
$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;
|
||||||
|
|
||||||
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[] = sprintf('"%s" as %s', $name, $alias);
|
$column_list[] = 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);
|
||||||
|
|
@ -964,8 +869,7 @@
|
||||||
$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);
|
||||||
}
|
}
|
||||||
|
|
@ -973,38 +877,32 @@
|
||||||
$now_matchs = null;
|
$now_matchs = null;
|
||||||
$column_list[] = sprintf ($click_count, sprintf ('%s.%s', $prefix, $name)) . ($alias ? sprintf (' as %s',$alias) : '');
|
$column_list[] = sprintf ($click_count, sprintf ('%s.%s', $prefix, $name)) . ($alias ? sprintf (' as %s',$alias) : '');
|
||||||
}
|
}
|
||||||
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$column_list[] = sprintf ($click_count, $name). ($alias ? sprintf (' as %s', $alias) : '');
|
$column_list[] = sprintf ($click_count, $name). ($alias ? sprintf (' as %s', $alias) : '');
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
$column_list[] = sprintf($click_count, $name). ($alias ? sprintf(' as %s',$alias) : '');
|
$column_list[] = sprintf($click_count, $name). ($alias ? sprintf(' as %s',$alias) : '');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1014,17 +912,14 @@
|
||||||
|
|
||||||
$condition = $this->getCondition ($output);
|
$condition = $this->getCondition ($output);
|
||||||
|
|
||||||
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
if($output->order)
|
if ($output->order) {
|
||||||
{
|
|
||||||
$conditions = $this->getConditionList($output);
|
$conditions = $this->getConditionList($output);
|
||||||
//if(in_array('list_order', $conditions) || in_array('update_order', $conditions)) {
|
//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;
|
||||||
if ($condition) $condition .= sprintf(' and %s < 2100000000 ', $col);
|
if ($condition) $condition .= sprintf(' and %s < 2100000000 ', $col);
|
||||||
|
|
@ -1035,23 +930,18 @@
|
||||||
|
|
||||||
$query = sprintf ("select %s from %s %s %s", $columns, implode (',',$table_list), implode (' ',$left_join), $condition);
|
$query = sprintf ("select %s from %s %s %s", $columns, implode (',',$table_list), implode (' ',$left_join), $condition);
|
||||||
|
|
||||||
if (count ($output->groups))
|
if (count ($output->groups)) {
|
||||||
{
|
foreach ($output->groups as $key => $value) {
|
||||||
foreach ($output->groups as $key => $value)
|
if (strpos ($value, '.')) {
|
||||||
{
|
|
||||||
if (strpos ($value, '.'))
|
|
||||||
{
|
|
||||||
$tmp = explode ('.', $value);
|
$tmp = explode ('.', $value);
|
||||||
$tmp[0] = sprintf ('"%s"', $tmp[0]);
|
$tmp[0] = sprintf ('"%s"', $tmp[0]);
|
||||||
$tmp[1] = sprintf ('"%s"', $tmp[1]);
|
$tmp[1] = sprintf ('"%s"', $tmp[1]);
|
||||||
$value = implode ('.', $tmp);
|
$value = implode ('.', $tmp);
|
||||||
}
|
}
|
||||||
elseif (strpos ($value, '('))
|
elseif (strpos ($value, '(')) {
|
||||||
{
|
|
||||||
$value = $value;
|
$value = $value;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
$value = sprintf ('"%s"', $value);
|
$value = sprintf ('"%s"', $value);
|
||||||
}
|
}
|
||||||
$output->groups[$key] = $value;
|
$output->groups[$key] = $value;
|
||||||
|
|
@ -1060,15 +950,12 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// list_count를 사용할 경우 적용
|
// list_count를 사용할 경우 적용
|
||||||
if ($output->list_count['value'])
|
if ($output->list_count['value']) {
|
||||||
{
|
|
||||||
$start_count = 0;
|
$start_count = 0;
|
||||||
$list_count = $output->list_count['value'];
|
$list_count = $output->list_count['value'];
|
||||||
|
|
||||||
if ($output->order)
|
if ($output->order) {
|
||||||
{
|
foreach ($output->order as $val) {
|
||||||
foreach ($output->order as $val)
|
|
||||||
{
|
|
||||||
if (strpos ($val[0], '.')) {
|
if (strpos ($val[0], '.')) {
|
||||||
$tmpval = explode ('.', $val[0]);
|
$tmpval = explode ('.', $val[0]);
|
||||||
$tmpval[0] = sprintf ('"%s"', $tmpval[0]);
|
$tmpval[0] = sprintf ('"%s"', $tmpval[0]);
|
||||||
|
|
@ -1084,33 +971,24 @@
|
||||||
$query .= ' order by '.implode(',', $index_list);
|
$query .= ' order by '.implode(',', $index_list);
|
||||||
$query = sprintf ('%s for orderby_num() between %d and %d', $query, $start_count + 1, $list_count + $start_count);
|
$query = sprintf ('%s for orderby_num() between %d and %d', $query, $start_count + 1, $list_count + $start_count);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
if (count ($output->groups)) {
|
||||||
if (count ($output->groups))
|
|
||||||
{
|
|
||||||
$query = sprintf ('%s having groupby_num() between %d'. ' and %d', $query, $start_count + 1, $list_count + $start_count);
|
$query = sprintf ('%s having groupby_num() between %d'. ' and %d', $query, $start_count + 1, $list_count + $start_count);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
if ($condition) {
|
||||||
if ($condition)
|
|
||||||
{
|
|
||||||
$query = sprintf ('%s and inst_num() between %d'. ' and %d', $query, $start_count + 1, $list_count + $start_count);
|
$query = sprintf ('%s and inst_num() between %d'. ' and %d', $query, $start_count + 1, $list_count + $start_count);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
$query = sprintf ('%s where inst_num() between %d'. ' and %d', $query, $start_count + 1, $list_count + $start_count);
|
$query = sprintf ('%s where inst_num() between %d'. ' and %d', $query, $start_count + 1, $list_count + $start_count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
if ($output->order) {
|
||||||
if ($output->order)
|
foreach ($output->order as $val) {
|
||||||
{
|
if (strpos ($val[0], '.')) {
|
||||||
foreach ($output->order as $val)
|
|
||||||
{
|
|
||||||
if (strpos ($val[0], '.'))
|
|
||||||
{
|
|
||||||
$tmpval = explode ('.', $val[0]);
|
$tmpval = explode ('.', $val[0]);
|
||||||
$tmpval[0] = sprintf ('"%s"', $tmpval[0]);
|
$tmpval[0] = sprintf ('"%s"', $tmpval[0]);
|
||||||
$tmpval[1] = sprintf ('"%s"', $tmpval[1]);
|
$tmpval[1] = sprintf ('"%s"', $tmpval[1]);
|
||||||
|
|
@ -1122,8 +1000,7 @@
|
||||||
$index_list[] = sprintf('%s %s', $val[0], $val[1]);
|
$index_list[] = sprintf('%s %s', $val[0], $val[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count ($index_list))
|
if (count ($index_list)) {
|
||||||
{
|
|
||||||
$query .= ' order by '.implode(',', $index_list);
|
$query .= ' order by '.implode(',', $index_list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1202,11 +1079,9 @@
|
||||||
|
|
||||||
$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;
|
||||||
$total_count = $this->getCountCache($output->tables, $count_condition);
|
$total_count = $this->getCountCache($output->tables, $count_condition);
|
||||||
if($total_count === false)
|
if ($total_count === false) {
|
||||||
{
|
|
||||||
$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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1225,12 +1100,10 @@
|
||||||
if (!$page) $page = 1;
|
if (!$page) $page = 1;
|
||||||
|
|
||||||
// 전체 페이지를 구함
|
// 전체 페이지를 구함
|
||||||
if ($total_count)
|
if ($total_count) {
|
||||||
{
|
|
||||||
$total_page = (int) (($total_count - 1) / $list_count) + 1;
|
$total_page = (int) (($total_count - 1) / $list_count) + 1;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
$total_page = 1;
|
$total_page = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1238,12 +1111,10 @@
|
||||||
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;
|
||||||
|
|
||||||
if($output->order)
|
if ($output->order) {
|
||||||
{
|
|
||||||
$conditions = $this->getConditionList($output);
|
$conditions = $this->getConditionList($output);
|
||||||
//if(in_array('list_order', $conditions) || in_array('update_order', $conditions)) {
|
//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;
|
||||||
if($condition) $condition .= sprintf(' and %s < 2100000000 ', $col);
|
if($condition) $condition .= sprintf(' and %s < 2100000000 ', $col);
|
||||||
|
|
@ -1254,12 +1125,9 @@
|
||||||
|
|
||||||
$query = sprintf ("select %s from %s %s %s", $columns, implode (',', $table_list), implode(' ', $left_join), $condition);
|
$query = sprintf ("select %s from %s %s %s", $columns, implode (',', $table_list), implode(' ', $left_join), $condition);
|
||||||
|
|
||||||
if (count ($output->groups))
|
if (count ($output->groups)) {
|
||||||
{
|
foreach ($output->groups as $key => $value) {
|
||||||
foreach ($output->groups as $key => $value)
|
if (strpos ($value, '.')) {
|
||||||
{
|
|
||||||
if (strpos ($value, '.'))
|
|
||||||
{
|
|
||||||
$tmp = explode ('.', $value);
|
$tmp = explode ('.', $value);
|
||||||
$tmp[0] = sprintf ('"%s"', $tmp[0]);
|
$tmp[0] = sprintf ('"%s"', $tmp[0]);
|
||||||
$tmp[1] = sprintf ('"%s"', $tmp[1]);
|
$tmp[1] = sprintf ('"%s"', $tmp[1]);
|
||||||
|
|
@ -1273,12 +1141,9 @@
|
||||||
$query .= sprintf (' group by %s', implode (',', $output->groups));
|
$query .= sprintf (' group by %s', implode (',', $output->groups));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($output->order)
|
if ($output->order) {
|
||||||
{
|
foreach ($output->order as $val) {
|
||||||
foreach ($output->order as $val)
|
if (strpos ($val[0], '.')) {
|
||||||
{
|
|
||||||
if (strpos ($val[0], '.'))
|
|
||||||
{
|
|
||||||
$tmpval = explode ('.', $val[0]);
|
$tmpval = explode ('.', $val[0]);
|
||||||
$tmpval[0] = sprintf ('"%s"', $tmpval[0]);
|
$tmpval[0] = sprintf ('"%s"', $tmpval[0]);
|
||||||
$tmpval[1] = sprintf ('"%s"', $tmpval[1]);
|
$tmpval[1] = sprintf ('"%s"', $tmpval[1]);
|
||||||
|
|
@ -1290,27 +1155,21 @@
|
||||||
$index_list[] = sprintf ('%s %s', $val[0], $val[1]);
|
$index_list[] = sprintf ('%s %s', $val[0], $val[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count ($index_list))
|
if (count ($index_list)) {
|
||||||
{
|
|
||||||
$query .= ' order by '.implode(',', $index_list);
|
$query .= ' order by '.implode(',', $index_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = sprintf ('%s for orderby_num() between %d and %d', $query, $start_count + 1, $list_count + $start_count);
|
$query = sprintf ('%s for orderby_num() between %d and %d', $query, $start_count + 1, $list_count + $start_count);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
if (count($output->groups)) {
|
||||||
if (count($output->groups))
|
|
||||||
{
|
|
||||||
$query = sprintf ('%s having groupby_num() between %d and %d', $query, $start_count + 1, $list_count + $start_count);
|
$query = sprintf ('%s having groupby_num() between %d and %d', $query, $start_count + 1, $list_count + $start_count);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
if ($condition) {
|
||||||
if ($condition)
|
|
||||||
{
|
|
||||||
$query = sprintf ('%s and inst_num() between %d and %d', $query, $start_count + 1, $list_count + $start_count);
|
$query = sprintf ('%s and inst_num() between %d and %d', $query, $start_count + 1, $list_count + $start_count);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
$query = sprintf('%s where inst_num() between %d and %d', $query, $start_count + 1, $list_count + $start_count);
|
$query = sprintf('%s where inst_num() between %d and %d', $query, $start_count + 1, $list_count + $start_count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1319,8 +1178,7 @@
|
||||||
$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):'';
|
||||||
$result = $this->_query ($query);
|
$result = $this->_query ($query);
|
||||||
|
|
||||||
if ($this->isError ())
|
if ($this->isError ()) {
|
||||||
{
|
|
||||||
$buff = new Object ();
|
$buff = new Object ();
|
||||||
$buff->total_count = 0;
|
$buff->total_count = 0;
|
||||||
$buff->total_page = 0;
|
$buff->total_page = 0;
|
||||||
|
|
@ -1333,12 +1191,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
$virtual_no = $total_count - ($page - 1) * $list_count;
|
$virtual_no = $total_count - ($page - 1) * $list_count;
|
||||||
while($tmp = cubrid_fetch ($result, CUBRID_OBJECT))
|
while ($tmp = cubrid_fetch ($result, CUBRID_OBJECT)) {
|
||||||
{
|
if ($tmp) {
|
||||||
if($tmp)
|
foreach ($tmp as $k => $v) {
|
||||||
{
|
|
||||||
foreach($tmp as $k => $v)
|
|
||||||
{
|
|
||||||
$tmp->{$k} = rtrim($v);
|
$tmp->{$k} = rtrim($v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue