reverse merge rollback

git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@10714 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
ovclas 2012-05-17 02:38:33 +00:00
parent e3685a7bd8
commit 3afad81016
44 changed files with 333 additions and 742 deletions

View file

@ -21,7 +21,6 @@
require(_XE_PATH_.'classes/xml/xmlquery/tags/column/ColumnTag.class.php');
require(_XE_PATH_.'classes/xml/xmlquery/tags/column/SelectColumnTag.class.php');
require(_XE_PATH_.'classes/xml/xmlquery/tags/column/InsertColumnTag.class.php');
require(_XE_PATH_.'classes/xml/xmlquery/tags/column/InsertColumnTagWithoutArgument.class.php');
require(_XE_PATH_.'classes/xml/xmlquery/tags/column/UpdateColumnTag.class.php');
require(_XE_PATH_.'classes/xml/xmlquery/tags/column/SelectColumnsTag.class.php');
require(_XE_PATH_.'classes/xml/xmlquery/tags/column/InsertColumnsTag.class.php');
@ -69,14 +68,14 @@
// Write query cache file
$parser = new QueryParser($xml_obj->query);
FileHandler::writeFile($cache_file, $parser->toString());
FileHandler::writeFile($cache_file, $parser->toString());
return $parser;
}
function parse($query_id = NULL, $xml_file = NULL, $cache_file = NULL)
{
$this->parse_xml_query($query_id, $xml_file, $cache_file);
$query_parser = &$this->parse_xml_query($query_id, $xml_file, $cache_file);
}
function getXmlFileContent($xml_file){

View file

@ -11,8 +11,8 @@
function getTableInfo($query_id, $table_name) {
$column_type = array();
$module = '';
$module = '';
$id_args = explode('.', $query_id);
if (count($id_args) == 2) {
$target = 'modules';

View file

@ -1,26 +0,0 @@
<?php
/**
* @class InsertColumnTagWithoutArgument
* @author Arnia Software
* @brief Models the <column> tag inside an XML Query file whose action is 'insert-select'
*
**/
class InsertColumnTagWithoutArgument extends ColumnTag {
function InsertColumnTagWithoutArgument($column) {
parent::ColumnTag($column->attrs->name);
$dbParser = DB::getParser();
$this->name = $dbParser->parseColumnName($this->name);
}
function getExpressionString(){
return sprintf('new Expression(\'%s\')', $this->name);
}
function getArgument(){
return null;
}
}
?>

View file

@ -19,7 +19,6 @@
foreach($xml_columns as $column){
if($column->name === 'query') $this->columns[] = new QueryTag($column, true);
else if(!isset($column->attrs->var) && !isset($column->attrs->default)) $this->columns[] = new InsertColumnTagWithoutArgument($column);
else $this->columns[] = new InsertColumnTag($column);
}
}

View file

@ -19,22 +19,19 @@
}
else
{
parent::ColumnTag($column->attrs->name);
$dbParser = DB::getParser();
parent::ColumnTag($column->attrs->name);
$dbParser = new DB(); $dbParser = &$dbParser->getParser();
$this->name = $dbParser->parseExpression($this->name);
$this->alias = $column->attrs->alias;
$this->click_count = $column->attrs->click_count;
}
}
}
function getExpressionString(){
if($this->name == '*') return "new StarExpression()";
if($this->click_count)
return sprintf('new ClickCountExpression(%s, %s, $args->%s)', $this->name, $this->alias,$this->click_count);
if(strpos($this->name, '$') === 0)
return sprintf('new SelectExpression($args->%s)', substr($this->name, 1));
$dbParser = DB::getParser();
return sprintf('new SelectExpression(\'%s\'%s)', $this->name, $this->alias ? ', \''.$dbParser->escape($this->alias) .'\'': '');
}

View file

@ -10,7 +10,6 @@ class QueryTag {
//xml tags
var $columns;
var $tables;
var $subquery;
var $conditions;
var $groups;
var $navigation;
@ -38,12 +37,9 @@ class QueryTag {
$this->getColumns();
$tables = $this->getTables();
$this->setTableColumnTypes($tables);
$this->getSubquery(); // Used for insert-select
$this->getConditions();
$this->getGroups();
$this->getNavigation();
$this->getPrebuff();
$this->getBuff();
}
@ -81,20 +77,19 @@ class QueryTag {
}
}
function getColumns(){
if($this->action == 'select'){
return $this->columns = new SelectColumnsTag($this->query->columns);
}else if($this->action == 'insert' || $this->action == 'insert-select'){
return $this->columns = new InsertColumnsTag($this->query->columns->column);
}else if($this->action == 'update') {
return $this->columns = new UpdateColumnsTag($this->query->columns->column);
}else if($this->action == 'delete') {
return $this->columns = null;
function getColumns() {
if ($this->action == 'select') {
return $this->columns = new SelectColumnsTag($this->query->columns);
} else if ($this->action == 'insert') {
return $this->columns = new InsertColumnsTag($this->query->columns->column);
} else if ($this->action == 'update') {
return $this->columns = new UpdateColumnsTag($this->query->columns->column);
} else if ($this->action == 'delete') {
return $this->columns = null;
}
}
function getPrebuff() {
if($this->isSubQuery) return;
// TODO Check if this work with arguments in join clause
$arguments = $this->getArguments();
@ -164,32 +159,24 @@ class QueryTag {
if ($this->columns)
$buff .= '$query->setColumns(' . $this->columns->toString() . ');' . PHP_EOL;
$buff .= '$query->setTables(' . $this->tables->toString() .');'.PHP_EOL;
if($this->action == 'insert-select')
$buff .= '$query->setSubquery(' . $this->subquery->toString() .');'.PHP_EOL;
$buff .= '$query->setConditions('.$this->conditions->toString() .');'.PHP_EOL;
$buff .= '$query->setGroups(' . $this->groups->toString() . ');'.PHP_EOL;
$buff .= '$query->setOrder(' . $this->navigation->getOrderByString() .');'.PHP_EOL;
$buff .= '$query->setLimit(' . $this->navigation->getLimitString() .');'.PHP_EOL;
$buff .= '$query->setTables(' . $this->tables->toString() . ');' . PHP_EOL;
$buff .= '$query->setConditions(' . $this->conditions->toString() . ');' . PHP_EOL;
$buff .= '$query->setGroups(' . $this->groups->toString() . ');' . PHP_EOL;
$buff .= '$query->setOrder(' . $this->navigation->getOrderByString() . ');' . PHP_EOL;
$buff .= '$query->setLimit(' . $this->navigation->getLimitString() . ');' . PHP_EOL;
$this->buff = $buff;
return $this->buff;
}
function getTables(){
function getTables() {
if($this->query->index_hint && ($this->query->index_hint->attrs->for == 'ALL' || Context::getDBType() == strtolower($this->query->index_hint->attrs->for)))
return $this->tables = new TablesTag($this->query->tables, $this->query->index_hint);
else
return $this->tables = new TablesTag($this->query->tables);
}
function getSubquery(){
if($this->query->query){
$this->subquery = new QueryTag($this->query->query, true);
}
}
function getConditions(){
function getConditions() {
return $this->conditions = new ConditionsTag($this->query->conditions);
}
@ -220,13 +207,11 @@ class QueryTag {
return $this->buff;
}
function getArguments(){
function getArguments() {
$arguments = array();
if ($this->columns)
$arguments = array_merge($arguments, $this->columns->getArguments());
if($this->action =='insert-select')
$arguments = array_merge($arguments, $this->subquery->getArguments());
$arguments = array_merge($arguments, $this->tables->getArguments());
$arguments = array_merge($arguments, $this->tables->getArguments());
$arguments = array_merge($arguments, $this->conditions->getArguments());
$arguments = array_merge($arguments, $this->navigation->getArguments());
return $arguments;

View file

@ -42,7 +42,7 @@
$this->tables[] = new QueryTag($tag, true);
}
else {
if(isset($indexes[$tag->attrs->name]) && $indexes[$tag->attrs->name])
if(isset($indexes) && $indexes && isset($indexes[$tag->attrs->name]))
$this->tables[] = new HintTableTag($tag, $indexes[$tag->attrs->name]);
else
$this->tables[] = new TableTag($tag);