mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-13 16:34:52 +09:00
Added Query object to hold together query parts. Updated structure of query cache file to return Query object. Added support for array query arguments - used in the IN clause. git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0-DB@8438 201d5d3c-b55e-5fd7-737f-ddc643e51545
124 lines
No EOL
3.9 KiB
PHP
124 lines
No EOL
3.9 KiB
PHP
<?php
|
|
|
|
class ConditionArgument extends Argument {
|
|
var $operation;
|
|
|
|
function ConditionArgument($name, $value, $operation){
|
|
parent::Argument($name, $value);
|
|
$this->operation = $operation;
|
|
}
|
|
|
|
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;
|
|
// }
|
|
|
|
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)."'";
|
|
*/
|
|
|
|
}
|
|
}
|
|
|
|
?>
|