mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-13 16:34:52 +09:00
Started unit tests for condition and argument classes.
git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0-DB@8577 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
7112d518c8
commit
76019a4b2b
15 changed files with 537 additions and 108 deletions
|
|
@ -17,113 +17,114 @@
|
|||
function createConditionValue(){
|
||||
if(!isset($this->value)) return;
|
||||
|
||||
$name = $this->column_name;
|
||||
$operation = $this->operation;
|
||||
$value = $this->value;
|
||||
|
||||
switch($operation) {
|
||||
case 'like_prefix' :
|
||||
$this->value = $value.'%';
|
||||
break;
|
||||
case 'like_tail' :
|
||||
$this-> value = '%'.$value;
|
||||
break;
|
||||
case 'like' :
|
||||
$this->value = '%'.$value.'%';
|
||||
break;
|
||||
case 'in' :
|
||||
if(is_array($value))
|
||||
{
|
||||
//$value = $this->addQuotesArray($value);
|
||||
//if($type=='number') return join(',',$value);
|
||||
//else
|
||||
//$this->value = "['". join("','",$value)."']";
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->value = $value;
|
||||
}
|
||||
break;
|
||||
}
|
||||
/*
|
||||
//if(!in_array($operation,array('in','notin','between')) && is_array($value)){
|
||||
// $value = join(',', $value);
|
||||
//}
|
||||
// Daca operatia nu este in, notin, between si coloana e de tip numeric
|
||||
// daca valoarea e array -> concatenare
|
||||
// daca valoarea nu e array si nici nu contine paranteze (nu e functie) -> return (int)
|
||||
// altfel return valoare
|
||||
|
||||
// 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(!is_array($value) && strpos($name, '.') !== false && strpos($value, '.') !== false) {
|
||||
// list($table_name, $column_name) = explode('.', $value);
|
||||
// if($column_type[$column_name]) return $value;
|
||||
// }
|
||||
$name = $this->column_name;
|
||||
$operation = $this->operation;
|
||||
$value = $this->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' :
|
||||
// if(is_array($value))
|
||||
// {
|
||||
// $value = $this->addQuotesArray($value);
|
||||
// if($type=='number') return join(',',$value);
|
||||
// else return "'". join("','",$value)."'";
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return $value;
|
||||
// }
|
||||
// break;
|
||||
// case 'in' :
|
||||
// if(is_array($value))
|
||||
// {
|
||||
// $value = $this->addQuotesArray($value);
|
||||
// if($type=='number') return join(',',$value);
|
||||
// else return "'". join("','",$value)."'";
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return $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."'";
|
||||
// }
|
||||
// }
|
||||
switch($operation) {
|
||||
case 'like_prefix' :
|
||||
$this->value = $value.'%';
|
||||
break;
|
||||
case 'like_tail' :
|
||||
$this->value = '%'.$value;
|
||||
break;
|
||||
case 'like' :
|
||||
$this->value = '%'.$value.'%';
|
||||
break;
|
||||
case 'in' :
|
||||
if(is_array($value))
|
||||
{
|
||||
//$value = $this->addQuotesArray($value);
|
||||
if($this->getType() == 'number')
|
||||
$this->value = "(" . join(',',$value) . ")";
|
||||
else
|
||||
$this->value = "('". join("','",$value)."')";
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->value = $value;
|
||||
}
|
||||
break;
|
||||
}
|
||||
/*
|
||||
//if(!in_array($operation,array('in','notin','between')) && is_array($value)){
|
||||
// $value = join(',', $value);
|
||||
//}
|
||||
// Daca operatia nu este in, notin, between si coloana e de tip numeric
|
||||
// daca valoarea e array -> concatenare
|
||||
// daca valoarea nu e array si nici nu contine paranteze (nu e functie) -> return (int)
|
||||
// altfel return valoare
|
||||
|
||||
// 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(!is_array($value) && strpos($name, '.') !== false && strpos($value, '.') !== false) {
|
||||
// list($table_name, $column_name) = explode('.', $value);
|
||||
// if($column_type[$column_name]) return $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' :
|
||||
// if(is_array($value))
|
||||
// {
|
||||
// $value = $this->addQuotesArray($value);
|
||||
// if($type=='number') return join(',',$value);
|
||||
// else return "'". join("','",$value)."'";
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return $value;
|
||||
// }
|
||||
// break;
|
||||
// case 'in' :
|
||||
// if(is_array($value))
|
||||
// {
|
||||
// $value = $this->addQuotesArray($value);
|
||||
// if($type=='number') return join(',',$value);
|
||||
// else return "'". join("','",$value)."'";
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return $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);
|
||||
}
|
||||
$this->value = $value;
|
||||
//return "'".$this->addQuotes($value)."'";
|
||||
*/
|
||||
|
||||
//return $value;
|
||||
break;
|
||||
default:
|
||||
if(!is_array($value)) $value = preg_replace('/(^\'|\'$){1}/', '', $value);
|
||||
}
|
||||
$this->value = $value;
|
||||
//return "'".$this->addQuotes($value)."'";
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
function getType(){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue