Issue 388 - Query cache error related table alias

git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@9544 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
ucorina 2011-10-10 15:54:09 +00:00
parent 92a49aa179
commit 308d1606a7
8 changed files with 94 additions and 14 deletions

View file

@ -26,6 +26,7 @@
require(_XE_PATH_.'classes/db/queryparts/expression/SelectExpression.class.php');
require(_XE_PATH_.'classes/db/queryparts/expression/InsertExpression.class.php');
require(_XE_PATH_.'classes/db/queryparts/expression/UpdateExpression.class.php');
require(_XE_PATH_.'classes/db/queryparts/expression/UpdateExpressionWithoutArgument.class.php');
require(_XE_PATH_.'classes/db/queryparts/table/Table.class.php');
require(_XE_PATH_.'classes/db/queryparts/table/JoinTable.class.php');
require(_XE_PATH_.'classes/db/queryparts/table/CubridTableWithHint.class.php');
@ -605,22 +606,22 @@
$columnsList = $query->getUpdateString($with_values);
if($columnsList == '') return new Object(-1, "Invalid query");
$tableName = $query->getFirstTableName();
if($tableName == '') return new Object(-1, "Invalid query");
$tables = $query->getFromString($with_values);
if($tables == '') return new Object(-1, "Invalid query");
$where = $query->getWhereString($with_values);
if($where != '') $where = ' WHERE ' . $where;
$priority = $with_priority?$query->getPriority():'';
return "UPDATE $priority $tableName SET $columnsList ".$where;
return "UPDATE $priority $tables SET $columnsList ".$where;
}
function getInsertSql($query, $with_values = true, $with_priority = false){
$tableName = $query->getFirstTableName();
$values = $query->getInsertString($with_values);
$priority = $with_priority?$query->getPriority():'';
return "INSERT $priority INTO $tableName \n $values";
}

View file

@ -0,0 +1,41 @@
<?php
/**
* @class UpdateExpression
* @author Arnia Software
* @brief
*
*/
class UpdateExpressionWithoutArgument extends UpdateExpression {
var $argument;
function UpdateExpressionWithoutArgument($column_name, $argument){
parent::Expression($column_name);
$this->argument = $argument;
}
function getExpression($with_value = true){
return "$this->column_name = $this->argument";
}
function getValue(){
// TODO Escape value according to column type instead of variable type
$value = $this->argument;
if(!is_numeric($value)) return "'".$value."'";
return $value;
}
function show(){
if(!$this->argument) return false;
$value = $this->argument;
if(!isset($value)) return false;
return true;
}
function getArgument(){
return null;
}
}
?>

View file

@ -11,7 +11,7 @@
static $number_of_arguments = 0;
$this->argument_name = $tag->attrs->var;
if(!$this->argument_name) $this->argument_name = $tag->attrs->name;
if(!$this->argument_name) $this->argument_name = str_replace('.', '_',$tag->attrs->name);
if(!$this->argument_name) $this->argument_name = str_replace('.', '_',$tag->attrs->column);
$this->variable_name = $this->argument_name;

View file

@ -11,18 +11,28 @@
class UpdateColumnTag extends ColumnTag {
var $argument;
var $default_value;
function UpdateColumnTag($column) {
parent::ColumnTag($column->attrs->name);
$dbParser = DB::getParser();
$this->name = $dbParser->parseColumnName($this->name);
$this->argument = new QueryArgument($column);
if($column->attrs->var)
$this->argument = new QueryArgument($column);
else
$this->default_value = $dbParser->parseColumnName($column->attrs->default);
}
function getExpressionString(){
if($this->argument)
return sprintf('new UpdateExpression(\'%s\', $%s_argument)'
, $this->name
, $this->argument->argument_name);
else {
return sprintf('new UpdateExpressionWithoutArgument(\'%s\', \'%s\')'
, $this->name
, $this->default_value);
}
}
function getArgument(){