mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-24 21:03:19 +09:00
Update new xml query classes with xe 1.5
with improved query argument support and update and delete queries git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0-DB@8378 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
5f9a5249ac
commit
7dbe0626b6
39 changed files with 1619 additions and 540 deletions
61
classes/xml/xmlquery/queryargument/DefaultValue.class.php
Normal file
61
classes/xml/xmlquery/queryargument/DefaultValue.class.php
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
|
||||
class DefaultValue {
|
||||
var $column_name;
|
||||
var $value;
|
||||
|
||||
function DefaultValue($column_name, $value){
|
||||
$this->column_name = $column_name;
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
function isString(){
|
||||
$str_pos = strpos($this->value, '(');
|
||||
if($str_pos===false) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
function toString(){
|
||||
if(!isset($this->value)) return;
|
||||
|
||||
$str_pos = strpos($this->value, '(');
|
||||
if($str_pos===false) return '"'.$this->value.'"';
|
||||
|
||||
$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\']';
|
||||
break;
|
||||
case 'unixtime' :
|
||||
$val = 'time()';
|
||||
break;
|
||||
case 'curdate' :
|
||||
$val = 'date("YmdHis")';
|
||||
break;
|
||||
case 'sequence' :
|
||||
$val = '$this->getNextSequence()';
|
||||
break;
|
||||
case 'plus' :
|
||||
$args = abs($args);
|
||||
// TODO Make sure column name is escaped
|
||||
$val = sprintf('"%s+%d"', $this->column_name, $args);
|
||||
break;
|
||||
case 'minus' :
|
||||
$args = abs($args);
|
||||
$val = sprintf('"%s-%d"', $this->column_name, $args);
|
||||
break;
|
||||
case 'multiply' :
|
||||
$args = intval($args);
|
||||
$val = sprintf('"%s*%d"', $this->column_name, $args);
|
||||
break;
|
||||
default :
|
||||
$val = '"' . $this->value . '"';
|
||||
}
|
||||
|
||||
return $val;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue