mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-27 14:22:54 +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,35 +1,46 @@
|
|||
<?php
|
||||
<?php
|
||||
|
||||
class DefaultValue {
|
||||
var $column_name;
|
||||
var $value;
|
||||
var $is_sequence = false;
|
||||
|
||||
var $is_operation = false;
|
||||
var $operation = '';
|
||||
|
||||
function DefaultValue($column_name, $value){
|
||||
$this->column_name = $column_name;
|
||||
$dbParser = &XmlQueryParser::getDBParser();
|
||||
$this->column_name = $dbParser->parseColumnName($column_name);
|
||||
$this->value = $value;
|
||||
$this->value = $this->_setValue();
|
||||
}
|
||||
|
||||
|
||||
function isString(){
|
||||
$str_pos = strpos($this->value, '(');
|
||||
if($str_pos===false) return true;
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function isSequence(){
|
||||
return $this->is_sequence;
|
||||
}
|
||||
|
||||
|
||||
function isOperation(){
|
||||
return $this->is_operation;
|
||||
}
|
||||
|
||||
function getOperation(){
|
||||
return $this->operation;
|
||||
}
|
||||
|
||||
function _setValue(){
|
||||
if(!isset($this->value)) return;
|
||||
|
||||
|
||||
// If value contains comma separated values and does not contain paranthesis
|
||||
// -> default value is an array
|
||||
if(strpos($this->value, ',') !== false && strpos($this->value, '(') === false) {
|
||||
return sprintf('array(%s)', $this->value);
|
||||
}
|
||||
|
||||
|
||||
$str_pos = strpos($this->value, '(');
|
||||
// // TODO Replace this with parseExpression
|
||||
if($str_pos===false) return '\''.$this->value.'\'';
|
||||
|
|
@ -37,7 +48,7 @@
|
|||
|
||||
$func_name = substr($this->value, 0, $str_pos);
|
||||
$args = substr($this->value, $str_pos+1, strlen($value)-1);
|
||||
|
||||
|
||||
switch($func_name) {
|
||||
case 'ipaddress' :
|
||||
$val = '$_SERVER[\'REMOTE_ADDR\']';
|
||||
|
|
@ -54,25 +65,30 @@
|
|||
break;
|
||||
case 'plus' :
|
||||
$args = abs($args);
|
||||
// TODO Make sure column name is escaped
|
||||
$val = sprintf('"%s+%d"', $this->column_name, $args);
|
||||
$this->is_operation = true;
|
||||
$this->operation = '+';
|
||||
$val = sprintf('%d', $args);
|
||||
break;
|
||||
case 'minus' :
|
||||
$args = abs($args);
|
||||
$val = sprintf('"%s-%d"', $this->column_name, $args);
|
||||
break;
|
||||
$this->is_operation = true;
|
||||
$this->operation = '-';
|
||||
$val = sprintf('%d', $args);
|
||||
break;
|
||||
case 'multiply' :
|
||||
$args = intval($args);
|
||||
$val = sprintf('"%s*%d"', $this->column_name, $args);
|
||||
$this->is_operation = true;
|
||||
$this->operation = '*';
|
||||
$val = sprintf('%d', $args);
|
||||
break;
|
||||
default :
|
||||
$val = '\'' . $this->value . '\'';
|
||||
//$val = $this->value;
|
||||
}
|
||||
|
||||
return $val;
|
||||
|
||||
return $val;
|
||||
}
|
||||
|
||||
|
||||
function toString(){
|
||||
return $this->value;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue