mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-04 09:32:15 +09:00
issue 2119. supporting php 5.4. db classes.
git-svn-id: http://xe-core.googlecode.com/svn/branches/maserati@12686 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
7fe03148f0
commit
41fdaf00c3
29 changed files with 1846 additions and 798 deletions
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @package /classes/db/queryparts/condition
|
||||
|
|
@ -6,12 +7,14 @@
|
|||
*/
|
||||
class Condition
|
||||
{
|
||||
|
||||
/**
|
||||
* column name
|
||||
* @var string
|
||||
*/
|
||||
var $column_name;
|
||||
var $argument;
|
||||
|
||||
/**
|
||||
* operation can use 'equal', 'more', 'excess', 'less', 'below', 'like_tail', 'like_prefix', 'like', 'notlike_tail',
|
||||
* 'notlike_prefix', 'notlike', 'in', 'notin', 'not_in', 'and', 'or', 'xor', 'not', 'notequal', 'between'
|
||||
|
|
@ -19,14 +22,13 @@ class Condition
|
|||
* @var string
|
||||
*/
|
||||
var $operation;
|
||||
|
||||
/**
|
||||
* pipe can use 'and', 'or'...
|
||||
* @var string
|
||||
*/
|
||||
var $pipe;
|
||||
|
||||
var $_value;
|
||||
|
||||
var $_show;
|
||||
var $_value_to_string;
|
||||
|
||||
|
|
@ -58,13 +60,13 @@ class Condition
|
|||
*/
|
||||
function toString($withValue = true)
|
||||
{
|
||||
if (!isset($this->_value_to_string))
|
||||
if(!isset($this->_value_to_string))
|
||||
{
|
||||
if (!$this->show())
|
||||
if(!$this->show())
|
||||
{
|
||||
$this->_value_to_string = '';
|
||||
}
|
||||
else if ($withValue)
|
||||
else if($withValue)
|
||||
{
|
||||
$this->_value_to_string = $this->toStringWithValue();
|
||||
}
|
||||
|
|
@ -135,17 +137,34 @@ class Condition
|
|||
case 'not':
|
||||
case 'notequal' :
|
||||
// if variable is not set or is not string or number, return
|
||||
if(!isset($this->_value)) { $this->_show = false; break;}
|
||||
if($this->_value === '') { $this->_show = false; break; }
|
||||
$tmpArray = array('string'=>1, 'integer'=>1);
|
||||
if(!isset($this->_value))
|
||||
{
|
||||
$this->_show = false;
|
||||
break;
|
||||
}
|
||||
if($this->_value === '')
|
||||
{
|
||||
$this->_show = false;
|
||||
break;
|
||||
}
|
||||
$tmpArray = array('string' => 1, 'integer' => 1);
|
||||
if(!isset($tmpArray[gettype($this->_value)]))
|
||||
{
|
||||
$this->_show = false; break;
|
||||
$this->_show = false;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'between' :
|
||||
if(!is_array($this->_value)) { $this->_show = false; break;}
|
||||
if(count($this->_value)!=2) {$this->_show = false; break;}
|
||||
if(!is_array($this->_value))
|
||||
{
|
||||
$this->_show = false;
|
||||
break;
|
||||
}
|
||||
if(count($this->_value) != 2)
|
||||
{
|
||||
$this->_show = false;
|
||||
break;
|
||||
}
|
||||
case 'null':
|
||||
case 'notnull':
|
||||
break;
|
||||
|
|
@ -171,67 +190,68 @@ class Condition
|
|||
switch($operation)
|
||||
{
|
||||
case 'equal' :
|
||||
return $name.' = '.$value;
|
||||
return $name . ' = ' . $value;
|
||||
break;
|
||||
case 'more' :
|
||||
return $name.' >= '.$value;
|
||||
return $name . ' >= ' . $value;
|
||||
break;
|
||||
case 'excess' :
|
||||
return $name.' > '.$value;
|
||||
return $name . ' > ' . $value;
|
||||
break;
|
||||
case 'less' :
|
||||
return $name.' <= '.$value;
|
||||
return $name . ' <= ' . $value;
|
||||
break;
|
||||
case 'below' :
|
||||
return $name.' < '.$value;
|
||||
return $name . ' < ' . $value;
|
||||
break;
|
||||
case 'like_tail' :
|
||||
case 'like_prefix' :
|
||||
case 'like' :
|
||||
if(defined('__CUBRID_VERSION__')
|
||||
&& __CUBRID_VERSION__ >= '8.4.1')
|
||||
return $name.' rlike '.$value;
|
||||
if(defined('__CUBRID_VERSION__')
|
||||
&& __CUBRID_VERSION__ >= '8.4.1')
|
||||
return $name . ' rlike ' . $value;
|
||||
else
|
||||
return $name.' like '.$value;
|
||||
return $name . ' like ' . $value;
|
||||
break;
|
||||
case 'notlike_tail' :
|
||||
case 'notlike_prefix' :
|
||||
case 'notlike' :
|
||||
return $name.' not like '.$value;
|
||||
return $name . ' not like ' . $value;
|
||||
break;
|
||||
case 'in' :
|
||||
return $name.' in '.$value;
|
||||
return $name . ' in ' . $value;
|
||||
break;
|
||||
case 'notin' :
|
||||
case 'not_in' :
|
||||
return $name.' not in '.$value;
|
||||
return $name . ' not in ' . $value;
|
||||
break;
|
||||
case 'notequal' :
|
||||
return $name.' <> '.$value;
|
||||
return $name . ' <> ' . $value;
|
||||
break;
|
||||
case 'notnull' :
|
||||
return $name.' is not null';
|
||||
return $name . ' is not null';
|
||||
break;
|
||||
case 'null' :
|
||||
return $name.' is null';
|
||||
return $name . ' is null';
|
||||
break;
|
||||
case 'and' :
|
||||
return $name.' & '.$value;
|
||||
return $name . ' & ' . $value;
|
||||
break;
|
||||
case 'or' :
|
||||
return $name.' | '.$value;
|
||||
return $name . ' | ' . $value;
|
||||
break;
|
||||
case 'xor' :
|
||||
return $name.' ^ '.$value;
|
||||
return $name . ' ^ ' . $value;
|
||||
break;
|
||||
case 'not' :
|
||||
return $name.' ~ '.$value;
|
||||
return $name . ' ~ ' . $value;
|
||||
break;
|
||||
case 'between' :
|
||||
return $name.' between ' . $value[0] . ' and ' . $value[1];
|
||||
return $name . ' between ' . $value[0] . ' and ' . $value[1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/* End of file Condition.class.php */
|
||||
/* Location: ./classes/db/queryparts/condition/Condition.class.php */
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @package /classes/db/queryparts/condition
|
||||
|
|
@ -6,17 +7,18 @@
|
|||
*/
|
||||
class ConditionGroup
|
||||
{
|
||||
|
||||
/**
|
||||
* condition list
|
||||
* @var array
|
||||
*/
|
||||
var $conditions;
|
||||
|
||||
/**
|
||||
* pipe can use 'and', 'or'...
|
||||
* @var string
|
||||
*/
|
||||
var $pipe;
|
||||
|
||||
var $_group;
|
||||
var $_show;
|
||||
|
||||
|
|
@ -32,10 +34,18 @@ class ConditionGroup
|
|||
foreach($conditions as $condition)
|
||||
{
|
||||
if($condition->show())
|
||||
{
|
||||
$this->conditions[] = $condition;
|
||||
}
|
||||
}
|
||||
if(count($this->conditions) === 0)
|
||||
{
|
||||
$this->_show = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_show = true;
|
||||
}
|
||||
if(count($this->conditions) === 0) $this->_show = false;
|
||||
else $this->_show = true;
|
||||
|
||||
$this->pipe = $pipe;
|
||||
}
|
||||
|
|
@ -47,7 +57,10 @@ class ConditionGroup
|
|||
|
||||
function setPipe($pipe)
|
||||
{
|
||||
if($this->pipe !== $pipe) $this->_group = null;
|
||||
if($this->pipe !== $pipe)
|
||||
{
|
||||
$this->_group = null;
|
||||
}
|
||||
$this->pipe = $pipe;
|
||||
}
|
||||
|
||||
|
|
@ -65,7 +78,10 @@ class ConditionGroup
|
|||
|
||||
foreach($this->conditions as $condition)
|
||||
{
|
||||
if($cond_indx === 0) $condition->setPipe("");
|
||||
if($cond_indx === 0)
|
||||
{
|
||||
$condition->setPipe("");
|
||||
}
|
||||
$group .= $condition->toString($with_value) . ' ';
|
||||
$cond_indx++;
|
||||
}
|
||||
|
|
@ -90,10 +106,14 @@ class ConditionGroup
|
|||
foreach($this->conditions as $condition)
|
||||
{
|
||||
$arg = $condition->getArgument();
|
||||
if($arg) $args[] = $arg;
|
||||
if($arg)
|
||||
{
|
||||
$args[] = $arg;
|
||||
}
|
||||
}
|
||||
return $args;
|
||||
}
|
||||
|
||||
}
|
||||
/* End of file ConditionGroup.class.php */
|
||||
/* Location: ./classes/db/queryparts/condition/ConditionGroup.class.php */
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @package /classes/db/queryparts/condition
|
||||
|
|
@ -6,6 +7,7 @@
|
|||
*/
|
||||
class ConditionSubquery extends Condition
|
||||
{
|
||||
|
||||
/**
|
||||
* constructor
|
||||
* @param string $column_name
|
||||
|
|
@ -19,6 +21,7 @@ class ConditionSubquery extends Condition
|
|||
parent::Condition($column_name, $argument, $operation, $pipe);
|
||||
$this->_value = $this->argument->toString();
|
||||
}
|
||||
|
||||
}
|
||||
/* End of file ConditionSubquery.class.php */
|
||||
/* Location: ./classes/db/queryparts/condition/ConditionSubquery.class.php */
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @package /classes/db/queryparts/condition
|
||||
|
|
@ -6,6 +7,7 @@
|
|||
*/
|
||||
class ConditionWithArgument extends Condition
|
||||
{
|
||||
|
||||
/**
|
||||
* constructor
|
||||
* @param string $column_name
|
||||
|
|
@ -16,14 +18,19 @@ class ConditionWithArgument extends Condition
|
|||
*/
|
||||
function ConditionWithArgument($column_name, $argument, $operation, $pipe = "")
|
||||
{
|
||||
if($argument === null) { $this->_show = false; return; }
|
||||
if($argument === null)
|
||||
{
|
||||
$this->_show = false;
|
||||
return;
|
||||
}
|
||||
parent::Condition($column_name, $argument, $operation, $pipe);
|
||||
$this->_value = $argument->getValue();
|
||||
}
|
||||
|
||||
function getArgument()
|
||||
{
|
||||
if(!$this->show()) return;
|
||||
if(!$this->show())
|
||||
return;
|
||||
return $this->argument;
|
||||
}
|
||||
|
||||
|
|
@ -38,11 +45,17 @@ class ConditionWithArgument extends Condition
|
|||
if(is_array($value))
|
||||
{
|
||||
$q = '';
|
||||
foreach ($value as $v) $q .= '?,';
|
||||
if($q !== '') $q = substr($q, 0, -1);
|
||||
foreach($value as $v)
|
||||
{
|
||||
$q .= '?,';
|
||||
}
|
||||
if($q !== '')
|
||||
{
|
||||
$q = substr($q, 0, -1);
|
||||
}
|
||||
$q = '(' . $q . ')';
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
// Prepared statements: column names should not be sent as query arguments, but instead concatenated to query string
|
||||
if($this->argument->isColumnName())
|
||||
|
|
@ -64,8 +77,14 @@ class ConditionWithArgument extends Condition
|
|||
{
|
||||
if(!isset($this->_show))
|
||||
{
|
||||
if(!$this->argument->isValid()) $this->_show = false;
|
||||
if($this->_value === '\'\'') $this->_show = false;
|
||||
if(!$this->argument->isValid())
|
||||
{
|
||||
$this->_show = false;
|
||||
}
|
||||
if($this->_value === '\'\'')
|
||||
{
|
||||
$this->_show = false;
|
||||
}
|
||||
if(!isset($this->_show))
|
||||
{
|
||||
return parent::show();
|
||||
|
|
@ -73,6 +92,7 @@ class ConditionWithArgument extends Condition
|
|||
}
|
||||
return $this->_show;
|
||||
}
|
||||
|
||||
}
|
||||
/* End of file ConditionWithArgument.class.php */
|
||||
/* Location: ./classes/db/queryparts/condition/ConditionWithArgument.class.php */
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @package /classes/db/queryparts/condition
|
||||
|
|
@ -6,6 +7,7 @@
|
|||
*/
|
||||
class ConditionWithoutArgument extends Condition
|
||||
{
|
||||
|
||||
/**
|
||||
* constructor
|
||||
* @param string $column_name
|
||||
|
|
@ -17,16 +19,21 @@ class ConditionWithoutArgument extends Condition
|
|||
function ConditionWithoutArgument($column_name, $argument, $operation, $pipe = "")
|
||||
{
|
||||
parent::Condition($column_name, $argument, $operation, $pipe);
|
||||
$tmpArray = array('in'=>1, 'notin'=>1, 'not_in'=>1);
|
||||
$tmpArray = array('in' => 1, 'notin' => 1, 'not_in' => 1);
|
||||
if(isset($tmpArray[$operation]))
|
||||
{
|
||||
if(is_array($argument)) $argument = implode($argument, ',');
|
||||
$this->_value = '('. $argument .')';
|
||||
if(is_array($argument))
|
||||
{
|
||||
$argument = implode($argument, ',');
|
||||
}
|
||||
$this->_value = '(' . $argument . ')';
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_value = $argument;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/* End of file ConditionWithoutArgument.class.php */
|
||||
/* Location: ./classes/db/queryparts/condition/ConditionWithoutArgument.class.php */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue