join query사용시에 value에 . 이 있을 경우 query fail이 나는 문제 해결

git-svn-id: http://xe-core.googlecode.com/svn/sandbox@2934 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
zero 2007-11-06 03:54:16 +00:00
parent cc74a3f5ec
commit 637e953a34
8 changed files with 13 additions and 20 deletions

View file

@ -316,12 +316,17 @@
* like, like_prefix의 경우 value자체가 변경됨 * like, like_prefix의 경우 value자체가 변경됨
* type == number가 아니면 addQuotes() 하고 ' ' 묶음 * type == number가 아니면 addQuotes() 하고 ' ' 묶음
**/ **/
function getConditionValue($name, $value, $operation, $type) { function getConditionValue($name, $value, $operation, $type, $column_type) {
if($type == 'number') { if($type == 'number') {
if(strpos($value,',')===false && strpos($value,'(')===false) return (int)$value; if(strpos($value,',')===false && strpos($value,'(')===false) return (int)$value;
return $value; return $value;
} }
if(strpos($value,'.')!==false) {
list($column_name) = explode('.',$value);
if($column_type[$column_name]) return $value;
}
$value = preg_replace('/(^\'|\'$){1}/','',$value); $value = preg_replace('/(^\'|\'$){1}/','',$value);
switch($operation) { switch($operation) {
@ -339,9 +344,6 @@
break; break;
} }
if(strpos($name,'.')!==false && strpos($value,'.')!==false) return $value;
return "'".$this->addQuotes($value)."'"; return "'".$this->addQuotes($value)."'";
} }

View file

@ -389,7 +389,7 @@
$type = $this->getColumnType($output->column_type,$name); $type = $this->getColumnType($output->column_type,$name);
$pipe = $v['pipe']; $pipe = $v['pipe'];
$value = $this->getConditionValue($name, $value, $operation, $type); $value = $this->getConditionValue($name, $value, $operation, $type, $output->column_type);
if(!$value) $value = $v['value']; if(!$value) $value = $v['value'];
if(strpos($name,'.')===false) $name = '"'.$name.'"'; if(strpos($name,'.')===false) $name = '"'.$name.'"';

View file

@ -374,7 +374,7 @@
$type = $this->getColumnType($output->column_type,$name); $type = $this->getColumnType($output->column_type,$name);
$pipe = $v['pipe']; $pipe = $v['pipe'];
$value = $this->getConditionValue($name, $value, $operation, $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.' ';

View file

@ -383,7 +383,7 @@
$type = $this->getColumnType($output->column_type,$name); $type = $this->getColumnType($output->column_type,$name);
$pipe = $v['pipe']; $pipe = $v['pipe'];
$value = $this->getConditionValue($name, $value, $operation, $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.' ';

View file

@ -360,7 +360,7 @@
$type = $this->getColumnType($output->column_type,$name); $type = $this->getColumnType($output->column_type,$name);
$pipe = $v['pipe']; $pipe = $v['pipe'];
$value = $this->getConditionValue($name, $value, $operation, $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.' ';

View file

@ -389,7 +389,7 @@
$type = $this->getColumnType($output->column_type,$name); $type = $this->getColumnType($output->column_type,$name);
$pipe = $v['pipe']; $pipe = $v['pipe'];
$value = $this->getConditionValue($name, $value, $operation, $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);

View file

@ -194,16 +194,7 @@
else $args->s_is_secret = ''; else $args->s_is_secret = '';
break; break;
case 'tag' : case 'tag' :
$oDB = &DB::getInstance(); $args->s_tags = str_replace(' ','%',$search_keyword);
$tmp_str_arr = explode(' ',$search_keyword);
$tmp_count = count($tmp_str_arr);
$tag_arr = array();
for($i=0;$i<$tmp_count;$i++) {
$tmp_str = trim($tmp_str_arr[$i]);
if(!$tmp_str) continue;
$tag_arr[] = $oDB->addQuotes($tmp_str);
}
$args->s_tags = "'".implode("','",$tag_arr);
$query_id = 'document.getDocumentListWithinTag'; $query_id = 'document.getDocumentListWithinTag';
break; break;
case 'readed_count' : case 'readed_count' :

View file

@ -9,7 +9,7 @@
<conditions> <conditions>
<condition operation="in" column="documents.module_srl" var="module_srl" filter="number" /> <condition operation="in" column="documents.module_srl" var="module_srl" filter="number" />
<condition operation="equal" column="documents.document_srl" default="tags.document_srl" notnull="notnull" pipe="and" /> <condition operation="equal" column="documents.document_srl" default="tags.document_srl" notnull="notnull" pipe="and" />
<condition operation="in" column="tags.tag" var="s_tags" notnull="notnull" pipe="and" /> <condition operation="like" column="tags.tag" var="s_tags" notnull="notnull" pipe="and" />
</conditions> </conditions>
<navigation> <navigation>
<index var="sort_index" default="documents.list_order" order="asc" /> <index var="sort_index" default="documents.list_order" order="asc" />