mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-10 12:32:14 +09:00
#19286156 XML Query Between 지원
git-svn-id: http://xe-core.googlecode.com/svn/sandbox@7890 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
3c5c2d214a
commit
c1401b4254
7 changed files with 64 additions and 16 deletions
|
|
@ -404,34 +404,60 @@
|
||||||
* @remarks if $type is not 'number', call addQuotes() and wrap with ' '
|
* @remarks if $type is not 'number', call addQuotes() and wrap with ' '
|
||||||
**/
|
**/
|
||||||
function getConditionValue($name, $value, $operation, $type, $column_type) {
|
function getConditionValue($name, $value, $operation, $type, $column_type) {
|
||||||
if($type == 'number') {
|
|
||||||
|
if(!in_array($operation,array('in','notin','between')) && $type == 'number') {
|
||||||
|
if(is_array($value)){
|
||||||
|
$value = join(',',$value);
|
||||||
|
}
|
||||||
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($name, '.') !== false && strpos($value, '.') !== false) {
|
if(!is_array($value) && strpos($name, '.') !== false && strpos($value, '.') !== false) {
|
||||||
list($table_name, $column_name) = explode('.', $value);
|
list($table_name, $column_name) = explode('.', $value);
|
||||||
if($column_type[$column_name]) return $value;
|
if($column_type[$column_name]) return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
$value = preg_replace('/(^\'|\'$){1}/', '', $value);
|
|
||||||
|
|
||||||
switch($operation) {
|
switch($operation) {
|
||||||
case 'like_prefix' :
|
case 'like_prefix' :
|
||||||
|
if(!is_array($value)) $value = preg_replace('/(^\'|\'$){1}/', '', $value);
|
||||||
$value = $value.'%';
|
$value = $value.'%';
|
||||||
break;
|
break;
|
||||||
case 'like_tail' :
|
case 'like_tail' :
|
||||||
|
if(!is_array($value)) $value = preg_replace('/(^\'|\'$){1}/', '', $value);
|
||||||
$value = '%'.$value;
|
$value = '%'.$value;
|
||||||
break;
|
break;
|
||||||
case 'like' :
|
case 'like' :
|
||||||
|
if(!is_array($value)) $value = preg_replace('/(^\'|\'$){1}/', '', $value);
|
||||||
$value = '%'.$value.'%';
|
$value = '%'.$value.'%';
|
||||||
break;
|
break;
|
||||||
case 'notin' :
|
case 'notin' :
|
||||||
return "'".$value."'";
|
if(!is_array($value)) $value = array($value);
|
||||||
|
$value = $this->addQuotesArray($value);
|
||||||
|
if($type=='number') return join(',',$value);
|
||||||
|
else return "'". join("','",$value)."'";
|
||||||
break;
|
break;
|
||||||
case 'in' :
|
case 'in' :
|
||||||
return "'".$value."'";
|
if(!is_array($value)) $value = array($value);
|
||||||
|
$value = $this->addQuotesArray($value);
|
||||||
|
if($type=='number') return join(',',$value);
|
||||||
|
else return "'". join("','",$value)."'";
|
||||||
break;
|
break;
|
||||||
|
case 'between' :
|
||||||
|
if(!is_array($value)) $value = array($value);
|
||||||
|
$value = $this->addQuotesArray($value);
|
||||||
|
if($type!='number')
|
||||||
|
{
|
||||||
|
foreach($value as $k=>$v)
|
||||||
|
{
|
||||||
|
$value[$k] = "'".$v."'";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $value;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if(!is_array($value)) $value = preg_replace('/(^\'|\'$){1}/', '', $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return "'".$this->addQuotes($value)."'";
|
return "'".$this->addQuotes($value)."'";
|
||||||
|
|
@ -461,6 +487,11 @@
|
||||||
if(!isset($value)) return;
|
if(!isset($value)) return;
|
||||||
if($value === '') return;
|
if($value === '') return;
|
||||||
if(!in_array(gettype($value), array('string', 'integer'))) return;
|
if(!in_array(gettype($value), array('string', 'integer'))) return;
|
||||||
|
break;
|
||||||
|
case 'between' :
|
||||||
|
if(!is_array($value)) return;
|
||||||
|
if(count($value)!=2) return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch($operation) {
|
switch($operation) {
|
||||||
|
|
@ -499,6 +530,9 @@
|
||||||
case 'null' :
|
case 'null' :
|
||||||
return $name.' is null';
|
return $name.' is null';
|
||||||
break;
|
break;
|
||||||
|
case 'between' :
|
||||||
|
return $name.' between ' . $value[0] . ' and ' . $value[1];
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -624,5 +658,22 @@
|
||||||
$query = sprintf("drop table %s%s", $this->prefix, $table_name);
|
$query = sprintf("drop table %s%s", $this->prefix, $table_name);
|
||||||
$this->_query($query);
|
$this->_query($query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addQuotesArray($arr)
|
||||||
|
{
|
||||||
|
if(is_array($arr))
|
||||||
|
{
|
||||||
|
foreach($arr as $k => $v)
|
||||||
|
{
|
||||||
|
$arr[$k] = $this->addQuotes($v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$arr = $this->addQuotes($arr);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $arr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -187,13 +187,11 @@
|
||||||
|
|
||||||
// 쿼리 문 실행
|
// 쿼리 문 실행
|
||||||
$result = @cubrid_execute ($this->fd, $query);
|
$result = @cubrid_execute ($this->fd, $query);
|
||||||
//if(!$result){ debugPrint('result null: ' .$query); }
|
|
||||||
// 오류 체크
|
// 오류 체크
|
||||||
if (cubrid_error_code ()) {
|
if (cubrid_error_code ()) {
|
||||||
$code = cubrid_error_code ();
|
$code = cubrid_error_code ();
|
||||||
$msg = cubrid_error_msg ();
|
$msg = cubrid_error_msg ();
|
||||||
|
|
||||||
//debugPrint('query error : '. $code.', msg:'. $msg .', ' .$query);
|
|
||||||
$this->setError ($code, $msg);
|
$this->setError ($code, $msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -308,7 +306,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->_query ($query);
|
$result = $this->_query ($query);
|
||||||
//if(!$result) debugPrint($query);
|
|
||||||
if (cubrid_num_rows($result) > 0) {
|
if (cubrid_num_rows($result) > 0) {
|
||||||
$output = true;
|
$output = true;
|
||||||
}
|
}
|
||||||
|
|
@ -577,7 +574,7 @@
|
||||||
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', 'array'))) continue;
|
||||||
|
|
||||||
$name = $v['column'];
|
$name = $v['column'];
|
||||||
$operation = $v['operation'];
|
$operation = $v['operation'];
|
||||||
|
|
|
||||||
|
|
@ -403,7 +403,7 @@
|
||||||
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', 'array'))) continue;
|
||||||
|
|
||||||
$name = $v['column'];
|
$name = $v['column'];
|
||||||
$operation = $v['operation'];
|
$operation = $v['operation'];
|
||||||
|
|
|
||||||
|
|
@ -412,7 +412,7 @@
|
||||||
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', 'array'))) continue;
|
||||||
|
|
||||||
$name = $v['column'];
|
$name = $v['column'];
|
||||||
$operation = $v['operation'];
|
$operation = $v['operation'];
|
||||||
|
|
|
||||||
|
|
@ -392,7 +392,7 @@
|
||||||
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', 'array'))) continue;
|
||||||
|
|
||||||
$name = $v['column'];
|
$name = $v['column'];
|
||||||
$operation = $v['operation'];
|
$operation = $v['operation'];
|
||||||
|
|
|
||||||
|
|
@ -528,7 +528,7 @@ class DBPostgresql extends DB
|
||||||
continue;
|
continue;
|
||||||
if ($v['value'] === '')
|
if ($v['value'] === '')
|
||||||
continue;
|
continue;
|
||||||
if (!in_array(gettype($v['value']), array('string', 'integer', 'double')))
|
if(!in_array(gettype($v['value']), array('string', 'integer', 'double', 'array'))) continue;
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
$name = $v['column'];
|
$name = $v['column'];
|
||||||
|
|
|
||||||
|
|
@ -414,7 +414,7 @@
|
||||||
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', 'array'))) continue;
|
||||||
|
|
||||||
$name = $v['column'];
|
$name = $v['column'];
|
||||||
$operation = $v['operation'];
|
$operation = $v['operation'];
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue