mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-04 09:32:15 +09:00
Fixed a few MSSQL bugs - related to array query arguments and increment columns.
git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0-DB@8632 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
6edd5f03a7
commit
b3c75ac4db
15 changed files with 411 additions and 276 deletions
|
|
@ -1,13 +1,13 @@
|
|||
<?php
|
||||
<?php
|
||||
|
||||
class Condition {
|
||||
var $column_name;
|
||||
var $argument;
|
||||
var $operation;
|
||||
var $pipe;
|
||||
|
||||
|
||||
var $_value;
|
||||
|
||||
|
||||
function Condition($column_name, $argument, $operation, $pipe = ""){
|
||||
$this->column_name = $column_name;
|
||||
$this->argument = $argument;
|
||||
|
|
@ -17,40 +17,50 @@
|
|||
$this->_value = $argument->getValue();
|
||||
else if(is_a($this->argument, 'Subquery'))
|
||||
$this->_value = $argument->toString();
|
||||
else
|
||||
else
|
||||
$this->_value = $argument;
|
||||
}
|
||||
|
||||
|
||||
function hasArgument(){
|
||||
return is_a($this->argument, 'Argument');
|
||||
}
|
||||
|
||||
|
||||
function getArgument(){
|
||||
if($this->hasArgument()) return $this->argument;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
function toString($withValue = true){
|
||||
if(!$this->show()) return '';
|
||||
if($withValue)
|
||||
return $this->toStringWithValue();
|
||||
return $this->toStringWithoutValue();
|
||||
}
|
||||
|
||||
|
||||
function toStringWithoutValue(){
|
||||
if($this->hasArgument())
|
||||
return $this->pipe . ' ' . $this->getConditionPart("?");
|
||||
if($this->hasArgument()){
|
||||
$value = $this->argument->getUnescapedValue();
|
||||
|
||||
if(is_array($value)){
|
||||
$q = '';
|
||||
foreach ($value as $v) $q .= '?,';
|
||||
if($q !== '') $q = substr($q, 0, -1);
|
||||
$q = '(' . $q . ')';
|
||||
}
|
||||
else $q = '?';
|
||||
return $this->pipe . ' ' . $this->getConditionPart($q);
|
||||
}
|
||||
else return $this->toString();
|
||||
}
|
||||
|
||||
|
||||
function toStringWithValue(){
|
||||
return $this->pipe . ' ' . $this->getConditionPart($this->_value);
|
||||
}
|
||||
|
||||
|
||||
function setPipe($pipe){
|
||||
$this->pipe = $pipe;
|
||||
}
|
||||
|
||||
|
||||
function show(){
|
||||
if($this->hasArgument() && !$this->argument->isValid()) return false;
|
||||
if($this->hasArgument() && ($this->_value === '\'\'')) return false;
|
||||
|
|
@ -75,14 +85,14 @@
|
|||
if(!is_array($this->_value)) return false;
|
||||
if(count($this->_value)!=2) return false;
|
||||
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
function getConditionPart($value) {
|
||||
$name = $this->column_name;
|
||||
$operation = $this->operation;
|
||||
|
||||
$operation = $this->operation;
|
||||
|
||||
switch($operation) {
|
||||
case 'equal' :
|
||||
return $name.' = '.$value;
|
||||
|
|
@ -123,7 +133,7 @@
|
|||
return $name.' between ' . $value[0] . ' and ' . $value[1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue