mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-08 19:42:15 +09:00
fix Argument and ConditionArgument type
git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0-DB@8563 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
013ada255d
commit
e9dca90031
3 changed files with 28 additions and 20 deletions
|
|
@ -3,6 +3,7 @@
|
||||||
class Argument {
|
class Argument {
|
||||||
var $value;
|
var $value;
|
||||||
var $name;
|
var $name;
|
||||||
|
var $type;
|
||||||
|
|
||||||
var $isValid;
|
var $isValid;
|
||||||
var $errorMessage;
|
var $errorMessage;
|
||||||
|
|
@ -13,6 +14,16 @@
|
||||||
$this->isValid = true;
|
$this->isValid = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getType(){
|
||||||
|
if(isset($this->type)) return $this->type;
|
||||||
|
if(is_string($this->value)) return 'column_name';
|
||||||
|
return 'number';
|
||||||
|
}
|
||||||
|
|
||||||
|
function setColumnType($value){
|
||||||
|
$this->type = $value;
|
||||||
|
}
|
||||||
|
|
||||||
function getName(){
|
function getName(){
|
||||||
return $this->name;
|
return $this->name;
|
||||||
}
|
}
|
||||||
|
|
@ -32,14 +43,22 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function escapeValue($value){
|
function escapeValue($value){
|
||||||
if(is_string($value)){
|
if($this->getType() == 'column_name'){
|
||||||
$dbParser = XmlQueryParser::getDBParser();
|
$dbParser = XmlQueryParser::getDBParser();
|
||||||
return $dbParser->parseExpression($value);
|
return $dbParser->parseExpression($value);
|
||||||
}
|
}
|
||||||
return $value;
|
if(in_array($this->type, array('date', 'varchar', 'char','text', 'bigtext'))){
|
||||||
}
|
if(!is_array($value))
|
||||||
|
$value = '\''.$value.'\'';
|
||||||
|
else {
|
||||||
|
$total = count($value);
|
||||||
|
for($i = 0; $i < $total; $i++)
|
||||||
|
$value[$i] = '\''.$value[$i].'\'';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function isValid(){
|
function isValid(){
|
||||||
return $this->isValid;
|
return $this->isValid;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
class ConditionArgument extends Argument {
|
class ConditionArgument extends Argument {
|
||||||
var $operation;
|
var $operation;
|
||||||
var $type;
|
|
||||||
|
|
||||||
function ConditionArgument($name, $value, $operation){
|
function ConditionArgument($name, $value, $operation){
|
||||||
parent::Argument($name, $value);
|
parent::Argument($name, $value);
|
||||||
|
|
@ -139,19 +139,7 @@
|
||||||
//if($column_type === '') $column_type = 'varchar';
|
//if($column_type === '') $column_type = 'varchar';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function escapeValue($value){
|
|
||||||
if(in_array($this->type, array('date', 'varchar', 'char','text', 'bigtext'))){
|
|
||||||
if(!is_array($value))
|
|
||||||
$value = '\''.$value.'\'';
|
|
||||||
else {
|
|
||||||
$total = count($value);
|
|
||||||
for($i = 0; $i < $total; $i++)
|
|
||||||
$value[$i] = '\''.$value[$i].'\'';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -86,10 +86,11 @@ class QueryTag {
|
||||||
foreach($arguments as $argument){
|
foreach($arguments as $argument){
|
||||||
if(isset($argument) && $argument->getArgumentName()){
|
if(isset($argument) && $argument->getArgumentName()){
|
||||||
$prebuff .= $argument->toString();
|
$prebuff .= $argument->toString();
|
||||||
if($argument->isConditionArgument())
|
$column_type = $this->column_type[$this->getQueryId()][$argument->getColumnName()];
|
||||||
|
if(isset($column_type))
|
||||||
$prebuff .= sprintf("$%s_argument->setColumnType('%s');\n"
|
$prebuff .= sprintf("$%s_argument->setColumnType('%s');\n"
|
||||||
, $argument->getArgumentName()
|
, $argument->getArgumentName()
|
||||||
, $this->column_type[$this->getQueryId()][$argument->getColumnName()] );
|
, $column_type );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$prebuff .= "\n";
|
$prebuff .= "\n";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue