mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-21 03:12:55 +09:00
reverse merge from 1.6.0 (r10013)
git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@10690 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
ac1783e77f
commit
75f9ef95cf
7 changed files with 116 additions and 26 deletions
|
|
@ -0,0 +1,27 @@
|
|||
<?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(){
|
||||
var_dump($this->name);
|
||||
return sprintf('new Expression(\'%s\')', $this->name);
|
||||
}
|
||||
|
||||
function getArgument(){
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ class QueryTag {
|
|||
//xml tags
|
||||
var $columns;
|
||||
var $tables;
|
||||
var $subquery;
|
||||
var $conditions;
|
||||
var $groups;
|
||||
var $navigation;
|
||||
|
|
@ -37,9 +38,12 @@ 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();
|
||||
}
|
||||
|
|
@ -77,19 +81,20 @@ class QueryTag {
|
|||
}
|
||||
}
|
||||
|
||||
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 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 getPrebuff() {
|
||||
if($this->isSubQuery) return;
|
||||
// TODO Check if this work with arguments in join clause
|
||||
$arguments = $this->getArguments();
|
||||
|
||||
|
|
@ -159,11 +164,13 @@ class QueryTag {
|
|||
if ($this->columns)
|
||||
$buff .= '$query->setColumns(' . $this->columns->toString() . ');' . 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;
|
||||
$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;
|
||||
|
||||
$this->buff = $buff;
|
||||
return $this->buff;
|
||||
|
|
@ -176,7 +183,13 @@ class QueryTag {
|
|||
return $this->tables = new TablesTag($this->query->tables);
|
||||
}
|
||||
|
||||
function getConditions() {
|
||||
function getSubquery(){
|
||||
if($this->query->query){
|
||||
$this->subquery = new QueryTag($this->query->query, true);
|
||||
}
|
||||
}
|
||||
|
||||
function getConditions(){
|
||||
return $this->conditions = new ConditionsTag($this->query->conditions);
|
||||
}
|
||||
|
||||
|
|
@ -207,11 +220,13 @@ class QueryTag {
|
|||
return $this->buff;
|
||||
}
|
||||
|
||||
function getArguments() {
|
||||
function getArguments(){
|
||||
$arguments = array();
|
||||
if ($this->columns)
|
||||
$arguments = array_merge($arguments, $this->columns->getArguments());
|
||||
$arguments = array_merge($arguments, $this->tables->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->conditions->getArguments());
|
||||
$arguments = array_merge($arguments, $this->navigation->getArguments());
|
||||
return $arguments;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue