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 {
|
class Argument {
|
||||||
var $value;
|
var $value;
|
||||||
var $name;
|
var $name;
|
||||||
var $type;
|
|
||||||
|
|
||||||
var $isValid;
|
var $isValid;
|
||||||
var $errorMessage;
|
var $errorMessage;
|
||||||
|
|
||||||
function Argument($name, $value){
|
function Argument($name, $value){
|
||||||
$this->name = $name;
|
$this->value = $value;
|
||||||
|
$this->name = $name;
|
||||||
if($this->type !== 'date'){
|
|
||||||
$dbParser = XmlQueryParser::getDBParser();
|
|
||||||
$this->value = $dbParser->escapeStringValue($value);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
$this->value = $value;
|
|
||||||
|
|
||||||
$this->isValid = true;
|
$this->isValid = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -40,22 +32,14 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function escapeValue($value){
|
function escapeValue($value){
|
||||||
if(in_array($this->type, array('date', 'varchar', 'char','text', 'bigtext'))){
|
if(is_string($value)){
|
||||||
if(!is_array($value))
|
$dbParser = XmlQueryParser::getDBParser();
|
||||||
$value = '\''.$value.'\'';
|
return $dbParser->parseExpression($value);
|
||||||
else {
|
}
|
||||||
$total = count($value);
|
return $value;
|
||||||
for($i = 0; $i < $total; $i++)
|
|
||||||
$value[$i] = '\''.$value[$i].'\'';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getType(){
|
|
||||||
return $this->type;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function isValid(){
|
function isValid(){
|
||||||
return $this->isValid;
|
return $this->isValid;
|
||||||
}
|
}
|
||||||
|
|
@ -69,15 +53,7 @@
|
||||||
$this->value = $default_value;
|
$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){
|
function checkFilter($filter_type){
|
||||||
if(isset($this->value) && $this->value != ''){
|
if(isset($this->value) && $this->value != ''){
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,16 @@
|
||||||
|
|
||||||
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);
|
||||||
$this->operation = $operation;
|
$this->operation = $operation;
|
||||||
|
|
||||||
|
if($this->type !== 'date'){
|
||||||
|
$dbParser = XmlQueryParser::getDBParser();
|
||||||
|
$this->value = $dbParser->escapeStringValue($this->value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function createConditionValue(){
|
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();
|
return $this->argument_validator->toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isConditionArgument(){
|
||||||
|
if($this->operation) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
function toString(){
|
function toString(){
|
||||||
if($this->operation)
|
if($this->isConditionArgument())
|
||||||
$arg = sprintf("\n$%s_argument = new ConditionArgument('%s', %s, '%s');\n"
|
$arg = sprintf("\n$%s_argument = new ConditionArgument('%s', %s, '%s');\n"
|
||||||
, $this->argument_name
|
, $this->argument_name
|
||||||
, $this->argument_name
|
, $this->argument_name
|
||||||
|
|
@ -67,7 +72,7 @@
|
||||||
|
|
||||||
$arg .= $this->argument_validator->toString();
|
$arg .= $this->argument_validator->toString();
|
||||||
|
|
||||||
if($this->operation){
|
if($this->isConditionArgument()){
|
||||||
$arg .= sprintf("$%s_argument->createConditionValue();\n"
|
$arg .= sprintf("$%s_argument->createConditionValue();\n"
|
||||||
, $this->argument_name
|
, $this->argument_name
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -10,11 +10,14 @@
|
||||||
function IndexTag($index){
|
function IndexTag($index){
|
||||||
$this->argument_name = $index->attrs->var;
|
$this->argument_name = $index->attrs->var;
|
||||||
|
|
||||||
$dbParser = XmlQueryParser::getDBParser();
|
// Sort index - column by which to sort
|
||||||
$index->attrs->default = $dbParser->parseExpression($index->attrs->default);
|
//$dbParser = XmlQueryParser::getDBParser();
|
||||||
|
//$index->attrs->default = $dbParser->parseExpression($index->attrs->default);
|
||||||
$this->default = $index->attrs->default;
|
$this->default = $index->attrs->default;
|
||||||
require_once(_XE_PATH_.'classes/xml/xmlquery/queryargument/QueryArgument.class.php');
|
require_once(_XE_PATH_.'classes/xml/xmlquery/queryargument/QueryArgument.class.php');
|
||||||
$this->argument = new QueryArgument($index);
|
$this->argument = new QueryArgument($index);
|
||||||
|
|
||||||
|
// Sort order - asc / desc
|
||||||
$this->sort_order = $index->attrs->order;
|
$this->sort_order = $index->attrs->order;
|
||||||
if(!in_array($this->sort_order, array("asc", "desc"))){
|
if(!in_array($this->sort_order, array("asc", "desc"))){
|
||||||
$arg->var = $this->sort_order;
|
$arg->var = $this->sort_order;
|
||||||
|
|
|
||||||
|
|
@ -86,9 +86,10 @@ 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();
|
||||||
$prebuff .= sprintf("$%s_argument->setColumnType('%s');\n"
|
if($argument->isConditionArgument())
|
||||||
, $argument->getArgumentName()
|
$prebuff .= sprintf("$%s_argument->setColumnType('%s');\n"
|
||||||
, $this->column_type[$this->getQueryId()][$argument->getColumnName()] );
|
, $argument->getArgumentName()
|
||||||
|
, $this->column_type[$this->getQueryId()][$argument->getColumnName()] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$prebuff .= "\n";
|
$prebuff .= "\n";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue