#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:
ngleader 2010-11-24 23:55:12 +00:00
parent 3c5c2d214a
commit c1401b4254
7 changed files with 64 additions and 16 deletions

View file

@ -404,34 +404,60 @@
* @remarks if $type is not 'number', call addQuotes() and wrap with ' '
**/
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;
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);
if($column_type[$column_name]) return $value;
}
$value = preg_replace('/(^\'|\'$){1}/', '', $value);
switch($operation) {
case 'like_prefix' :
if(!is_array($value)) $value = preg_replace('/(^\'|\'$){1}/', '', $value);
$value = $value.'%';
break;
case 'like_tail' :
if(!is_array($value)) $value = preg_replace('/(^\'|\'$){1}/', '', $value);
$value = '%'.$value;
break;
case 'like' :
if(!is_array($value)) $value = preg_replace('/(^\'|\'$){1}/', '', $value);
$value = '%'.$value.'%';
break;
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;
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;
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)."'";
@ -461,6 +487,11 @@
if(!isset($value)) return;
if($value === '') 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) {
@ -499,6 +530,9 @@
case 'null' :
return $name.' is null';
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);
$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;
}
}
?>

View file

@ -187,13 +187,11 @@
// 쿼리 문 실행
$result = @cubrid_execute ($this->fd, $query);
//if(!$result){ debugPrint('result null: ' .$query); }
// 오류 체크
if (cubrid_error_code ()) {
$code = cubrid_error_code ();
$msg = cubrid_error_msg ();
//debugPrint('query error : '. $code.', msg:'. $msg .', ' .$query);
$this->setError ($code, $msg);
}
@ -308,7 +306,6 @@
}
$result = $this->_query ($query);
//if(!$result) debugPrint($query);
if (cubrid_num_rows($result) > 0) {
$output = true;
}
@ -577,7 +574,7 @@
foreach ($val['condition'] as $v) {
if (!isset ($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'];
$operation = $v['operation'];

View file

@ -403,7 +403,7 @@
foreach($val['condition'] as $v) {
if(!isset($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'];
$operation = $v['operation'];

View file

@ -412,7 +412,7 @@
foreach($val['condition'] as $v) {
if(!isset($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'];
$operation = $v['operation'];

View file

@ -392,7 +392,7 @@
foreach($val['condition'] as $v) {
if(!isset($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'];
$operation = $v['operation'];

View file

@ -528,7 +528,7 @@ class DBPostgresql extends DB
continue;
if ($v['value'] === '')
continue;
if (!in_array(gettype($v['value']), array('string', 'integer', 'double')))
if(!in_array(gettype($v['value']), array('string', 'integer', 'double', 'array'))) continue;
continue;
$name = $v['column'];

View file

@ -414,7 +414,7 @@
foreach($val['condition'] as $v) {
if(!isset($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'];
$operation = $v['operation'];