mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-14 00:39:57 +09:00
fix Argument and Condition argument type
git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0-DB@8562 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
909276e16b
commit
013ada255d
5 changed files with 61 additions and 41 deletions
|
|
@ -3,21 +3,13 @@
|
|||
class Argument {
|
||||
var $value;
|
||||
var $name;
|
||||
var $type;
|
||||
|
||||
var $isValid;
|
||||
var $errorMessage;
|
||||
|
||||
function Argument($name, $value){
|
||||
$this->name = $name;
|
||||
|
||||
if($this->type !== 'date'){
|
||||
$dbParser = XmlQueryParser::getDBParser();
|
||||
$this->value = $dbParser->escapeStringValue($value);
|
||||
}
|
||||
else
|
||||
$this->value = $value;
|
||||
|
||||
$this->value = $value;
|
||||
$this->name = $name;
|
||||
$this->isValid = true;
|
||||
}
|
||||
|
||||
|
|
@ -40,22 +32,14 @@
|
|||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
function getType(){
|
||||
return $this->type;
|
||||
if(is_string($value)){
|
||||
$dbParser = XmlQueryParser::getDBParser();
|
||||
return $dbParser->parseExpression($value);
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
||||
function isValid(){
|
||||
return $this->isValid;
|
||||
}
|
||||
|
|
@ -69,15 +53,7 @@
|
|||
$this->value = $default_value;
|
||||
}
|
||||
|
||||
function setColumnType($column_type){
|
||||
if(!isset($this->value)) return;
|
||||
if($column_type === '') return;
|
||||
|
||||
$this->type = $column_type;
|
||||
|
||||
//if($column_type === '') $column_type = 'varchar';
|
||||
|
||||
}
|
||||
|
||||
function checkFilter($filter_type){
|
||||
if(isset($this->value) && $this->value != ''){
|
||||
|
|
|
|||
|
|
@ -2,10 +2,16 @@
|
|||
|
||||
class ConditionArgument extends Argument {
|
||||
var $operation;
|
||||
|
||||
var $type;
|
||||
|
||||
function ConditionArgument($name, $value, $operation){
|
||||
parent::Argument($name, $value);
|
||||
$this->operation = $operation;
|
||||
|
||||
if($this->type !== 'date'){
|
||||
$dbParser = XmlQueryParser::getDBParser();
|
||||
$this->value = $dbParser->escapeStringValue($this->value);
|
||||
}
|
||||
}
|
||||
|
||||
function createConditionValue(){
|
||||
|
|
@ -119,6 +125,35 @@
|
|||
*/
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function getType(){
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
function setColumnType($column_type){
|
||||
if(!isset($this->value)) return;
|
||||
if($column_type === '') return;
|
||||
|
||||
$this->type = $column_type;
|
||||
|
||||
//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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -49,8 +49,13 @@
|
|||
return $this->argument_validator->toString();
|
||||
}
|
||||
|
||||
function isConditionArgument(){
|
||||
if($this->operation) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
function toString(){
|
||||
if($this->operation)
|
||||
if($this->isConditionArgument())
|
||||
$arg = sprintf("\n$%s_argument = new ConditionArgument('%s', %s, '%s');\n"
|
||||
, $this->argument_name
|
||||
, $this->argument_name
|
||||
|
|
@ -67,7 +72,7 @@
|
|||
|
||||
$arg .= $this->argument_validator->toString();
|
||||
|
||||
if($this->operation){
|
||||
if($this->isConditionArgument()){
|
||||
$arg .= sprintf("$%s_argument->createConditionValue();\n"
|
||||
, $this->argument_name
|
||||
);
|
||||
|
|
|
|||
|
|
@ -10,11 +10,14 @@
|
|||
function IndexTag($index){
|
||||
$this->argument_name = $index->attrs->var;
|
||||
|
||||
$dbParser = XmlQueryParser::getDBParser();
|
||||
$index->attrs->default = $dbParser->parseExpression($index->attrs->default);
|
||||
// Sort index - column by which to sort
|
||||
//$dbParser = XmlQueryParser::getDBParser();
|
||||
//$index->attrs->default = $dbParser->parseExpression($index->attrs->default);
|
||||
$this->default = $index->attrs->default;
|
||||
require_once(_XE_PATH_.'classes/xml/xmlquery/queryargument/QueryArgument.class.php');
|
||||
$this->argument = new QueryArgument($index);
|
||||
|
||||
// Sort order - asc / desc
|
||||
$this->sort_order = $index->attrs->order;
|
||||
if(!in_array($this->sort_order, array("asc", "desc"))){
|
||||
$arg->var = $this->sort_order;
|
||||
|
|
|
|||
|
|
@ -86,9 +86,10 @@ class QueryTag {
|
|||
foreach($arguments as $argument){
|
||||
if(isset($argument) && $argument->getArgumentName()){
|
||||
$prebuff .= $argument->toString();
|
||||
$prebuff .= sprintf("$%s_argument->setColumnType('%s');\n"
|
||||
, $argument->getArgumentName()
|
||||
, $this->column_type[$this->getQueryId()][$argument->getColumnName()] );
|
||||
if($argument->isConditionArgument())
|
||||
$prebuff .= sprintf("$%s_argument->setColumnType('%s');\n"
|
||||
, $argument->getArgumentName()
|
||||
, $this->column_type[$this->getQueryId()][$argument->getColumnName()] );
|
||||
}
|
||||
}
|
||||
$prebuff .= "\n";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue