mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-14 00:39:57 +09:00
issue 262 coding convention in classes
git-svn-id: http://xe-core.googlecode.com/svn/branches/maserati@12230 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
cf271c0a98
commit
d5a46e5e90
27 changed files with 1840 additions and 1625 deletions
|
|
@ -1,122 +1,127 @@
|
|||
<?php
|
||||
/**
|
||||
* ConditionArgument class
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @package /classes/xml/xmlquery/argument
|
||||
* @version 0.1
|
||||
*/
|
||||
class ConditionArgument extends Argument
|
||||
{
|
||||
/**
|
||||
* ConditionArgument class
|
||||
* @author NHN (developers@xpressengine.com)
|
||||
* @package /classes/xml/xmlquery/argument
|
||||
* @version 0.1
|
||||
* Operator keyword. for example 'in', 'notint', 'between'
|
||||
* @var string
|
||||
*/
|
||||
class ConditionArgument extends Argument {
|
||||
/**
|
||||
* Operator keyword. for example 'in', 'notint', 'between'
|
||||
* @var string
|
||||
*/
|
||||
var $operation;
|
||||
var $operation;
|
||||
|
||||
|
||||
/**
|
||||
* constructor
|
||||
* @param string $name
|
||||
* @param mixed $value
|
||||
* @param string $operation
|
||||
* @return void
|
||||
*/
|
||||
function ConditionArgument($name, $value, $operation){
|
||||
$operationList = array('in'=>1, 'notin'=>1, 'not_in'=>1, 'between'=>1);
|
||||
if(isset($value) && isset($operationList[$operation]) && !is_array($value) && $value != ''){
|
||||
$value = str_replace(' ', '', $value);
|
||||
$value = str_replace('\'', '', $value);
|
||||
$value = explode(',', $value);
|
||||
}
|
||||
parent::Argument($name, $value);
|
||||
$this->operation = $operation;
|
||||
/**
|
||||
* constructor
|
||||
* @param string $name
|
||||
* @param mixed $value
|
||||
* @param string $operation
|
||||
* @return void
|
||||
*/
|
||||
function ConditionArgument($name, $value, $operation)
|
||||
{
|
||||
$operationList = array('in'=>1, 'notin'=>1, 'not_in'=>1, 'between'=>1);
|
||||
if(isset($value) && isset($operationList[$operation]) && !is_array($value) && $value != '')
|
||||
{
|
||||
$value = str_replace(' ', '', $value);
|
||||
$value = str_replace('\'', '', $value);
|
||||
$value = explode(',', $value);
|
||||
}
|
||||
parent::Argument($name, $value);
|
||||
$this->operation = $operation;
|
||||
}
|
||||
|
||||
/**
|
||||
* create condition value. set $this->value
|
||||
* @return void
|
||||
*/
|
||||
function createConditionValue(){
|
||||
if(!isset($this->value)) return;
|
||||
/**
|
||||
* create condition value. set $this->value
|
||||
* @return void
|
||||
*/
|
||||
function createConditionValue()
|
||||
{
|
||||
if(!isset($this->value)) return;
|
||||
|
||||
$operation = $this->operation;
|
||||
$value = $this->value;
|
||||
$operation = $this->operation;
|
||||
$value = $this->value;
|
||||
|
||||
switch($operation) {
|
||||
case 'like_prefix' :
|
||||
if(defined('__CUBRID_VERSION__')
|
||||
&& __CUBRID_VERSION__ >= '8.4.1') {
|
||||
$this->value = '^' . str_replace('%', '(.*)', preg_quote($value));
|
||||
}
|
||||
else
|
||||
$this->value = $value.'%';
|
||||
break;
|
||||
case 'like_tail' :
|
||||
if(defined('__CUBRID_VERSION__')
|
||||
&& __CUBRID_VERSION__ >= '8.4.1')
|
||||
$this->value = str_replace('%', '(.*)', preg_quote($value)) . '$';
|
||||
else
|
||||
$this->value = '%'.$value;
|
||||
break;
|
||||
case 'like' :
|
||||
if(defined('__CUBRID_VERSION__')
|
||||
&& __CUBRID_VERSION__ >= '8.4.1') {
|
||||
$this->value = str_replace('%', '(.*)', preg_quote($value));
|
||||
}
|
||||
else
|
||||
$this->value = '%'.$value.'%';
|
||||
break;
|
||||
case 'notlike' :
|
||||
$this->value = '%'.$value.'%';
|
||||
break;
|
||||
case 'notlike_prefix' :
|
||||
$this->value = $value.'%';
|
||||
break;
|
||||
case 'notlike_tail' :
|
||||
$this->value = '%'.$value;
|
||||
break;
|
||||
case 'in':
|
||||
if(!is_array($value)) $this->value = array($value);
|
||||
break;
|
||||
case 'notin':
|
||||
case 'not_in':
|
||||
if(!is_array($value)) $this->value = array($value);
|
||||
break;
|
||||
}
|
||||
switch($operation)
|
||||
{
|
||||
case 'like_prefix' :
|
||||
if(defined('__CUBRID_VERSION__') && __CUBRID_VERSION__ >= '8.4.1')
|
||||
{
|
||||
$this->value = '^' . str_replace('%', '(.*)', preg_quote($value));
|
||||
}
|
||||
else
|
||||
$this->value = $value.'%';
|
||||
break;
|
||||
case 'like_tail' :
|
||||
if(defined('__CUBRID_VERSION__') && __CUBRID_VERSION__ >= '8.4.1')
|
||||
$this->value = str_replace('%', '(.*)', preg_quote($value)) . '$';
|
||||
else
|
||||
$this->value = '%'.$value;
|
||||
break;
|
||||
case 'like' :
|
||||
if(defined('__CUBRID_VERSION__') && __CUBRID_VERSION__ >= '8.4.1')
|
||||
{
|
||||
$this->value = str_replace('%', '(.*)', preg_quote($value));
|
||||
}
|
||||
else
|
||||
$this->value = '%'.$value.'%';
|
||||
break;
|
||||
case 'notlike' :
|
||||
$this->value = '%'.$value.'%';
|
||||
break;
|
||||
case 'notlike_prefix' :
|
||||
$this->value = $value.'%';
|
||||
break;
|
||||
case 'notlike_tail' :
|
||||
$this->value = '%'.$value;
|
||||
break;
|
||||
case 'in':
|
||||
if(!is_array($value)) $this->value = array($value);
|
||||
break;
|
||||
case 'notin':
|
||||
case 'not_in':
|
||||
if(!is_array($value)) $this->value = array($value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Since ConditionArgument is used in WHERE clause,
|
||||
* where the argument value is compared to a table column,
|
||||
* it is assumed that all arguments have type. There are cases though
|
||||
* where the column does not have any type - if it was removed from
|
||||
* the XML schema for example - see the is_secret column in xe_documents table.
|
||||
* In this case, the column type is retrieved according to argument
|
||||
* value type (using the PHP function is_numeric).
|
||||
*
|
||||
* @return type string
|
||||
*/
|
||||
function getType(){
|
||||
if($this->type)
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
else if(!is_numeric($this->value))
|
||||
{
|
||||
return 'varchar';
|
||||
}
|
||||
else
|
||||
{
|
||||
return '';
|
||||
}
|
||||
/**
|
||||
* Since ConditionArgument is used in WHERE clause,
|
||||
* where the argument value is compared to a table column,
|
||||
* it is assumed that all arguments have type. There are cases though
|
||||
* where the column does not have any type - if it was removed from
|
||||
* the XML schema for example - see the is_secret column in xe_documents table.
|
||||
* In this case, the column type is retrieved according to argument
|
||||
* value type (using the PHP function is_numeric).
|
||||
*
|
||||
* @return type string
|
||||
*/
|
||||
function getType()
|
||||
{
|
||||
if($this->type)
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
function setColumnType($column_type){
|
||||
if(!isset($this->value)) return;
|
||||
if($column_type === '') return;
|
||||
|
||||
$this->type = $column_type;
|
||||
else if(!is_numeric($this->value))
|
||||
{
|
||||
return 'varchar';
|
||||
}
|
||||
else
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
function setColumnType($column_type)
|
||||
{
|
||||
if(!isset($this->value)) return;
|
||||
if($column_type === '') return;
|
||||
|
||||
?>
|
||||
$this->type = $column_type;
|
||||
}
|
||||
|
||||
}
|
||||
/* End of file ConditionArgument.class.php */
|
||||
/* Location: ./classes/xml/xmlquery/argument/ConditionArgument.class.php */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue