mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-28 23:03:25 +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 ' '
|
||||
**/
|
||||
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;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue