mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-06 18:21:39 +09:00
Condition pipe defaults to AND
XML 쿼리 작성시 pipe="and"를 일일이 추가하지 않아도 기본값이 AND가 되도록 함
This commit is contained in:
parent
83362034cd
commit
efa1b603c4
4 changed files with 16 additions and 9 deletions
|
|
@ -41,12 +41,12 @@ class Condition
|
||||||
* @param string $pipe
|
* @param string $pipe
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function __construct($column_name, $argument, $operation, $pipe)
|
function __construct($column_name, $argument, $operation, $pipe = 'and')
|
||||||
{
|
{
|
||||||
$this->column_name = $column_name;
|
$this->column_name = $column_name;
|
||||||
$this->argument = $argument;
|
$this->argument = $argument;
|
||||||
$this->operation = $operation;
|
$this->operation = $operation;
|
||||||
$this->pipe = strtoupper($pipe);
|
$this->pipe = $pipe;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getArgument()
|
function getArgument()
|
||||||
|
|
@ -85,7 +85,7 @@ class Condition
|
||||||
*/
|
*/
|
||||||
function toStringWithoutValue()
|
function toStringWithoutValue()
|
||||||
{
|
{
|
||||||
return $this->pipe . ' ' . $this->getConditionPart($this->_value);
|
return strtoupper($this->pipe) . ' ' . $this->getConditionPart($this->_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -94,7 +94,7 @@ class Condition
|
||||||
*/
|
*/
|
||||||
function toStringWithValue()
|
function toStringWithValue()
|
||||||
{
|
{
|
||||||
return $this->pipe . ' ' . $this->getConditionPart($this->_value);
|
return strtoupper($this->pipe) . ' ' . $this->getConditionPart($this->_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setPipe($pipe)
|
function setPipe($pipe)
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ class ConditionGroup
|
||||||
* @param string $pipe
|
* @param string $pipe
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function __construct($conditions, $pipe = "")
|
function __construct($conditions, $pipe = 'and')
|
||||||
{
|
{
|
||||||
$this->conditions = array();
|
$this->conditions = array();
|
||||||
foreach($conditions as $condition)
|
foreach($conditions as $condition)
|
||||||
|
|
@ -89,7 +89,7 @@ class ConditionGroup
|
||||||
|
|
||||||
if($this->pipe !== "" && trim($group) !== '')
|
if($this->pipe !== "" && trim($group) !== '')
|
||||||
{
|
{
|
||||||
$group = $this->pipe . ' (' . $group . ')';
|
$group = strtoupper($this->pipe) . ' (' . $group . ')';
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_group = $group;
|
$this->_group = $group;
|
||||||
|
|
|
||||||
|
|
@ -43,10 +43,17 @@ class JoinTable extends Table
|
||||||
{
|
{
|
||||||
$part = strtoupper($this->join_type) . ' ' . $this->name;
|
$part = strtoupper($this->join_type) . ' ' . $this->name;
|
||||||
$part .= $this->alias ? (' AS ' . $this->alias) : '';
|
$part .= $this->alias ? (' AS ' . $this->alias) : '';
|
||||||
$part .= ' ON ';
|
$part .= ' ON ';
|
||||||
|
|
||||||
|
$condition_count = 0;
|
||||||
foreach($this->conditions as $conditionGroup)
|
foreach($this->conditions as $conditionGroup)
|
||||||
{
|
{
|
||||||
$part .= $conditionGroup->toString($with_value);
|
if($condition_count === 0)
|
||||||
|
{
|
||||||
|
$conditionGroup->setPipe("");
|
||||||
|
}
|
||||||
|
$part .= $conditionGroup->toString($with_value);
|
||||||
|
$condition_count++;
|
||||||
}
|
}
|
||||||
return $part;
|
return $part;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ class ConditionTag
|
||||||
function __construct($condition)
|
function __construct($condition)
|
||||||
{
|
{
|
||||||
$this->operation = $condition->attrs->operation;
|
$this->operation = $condition->attrs->operation;
|
||||||
$this->pipe = $condition->attrs->pipe;
|
$this->pipe = $condition->attrs->pipe ?: 'and';
|
||||||
$dbParser = DB::getParser();
|
$dbParser = DB::getParser();
|
||||||
$this->column_name = $dbParser->parseExpression($condition->attrs->column);
|
$this->column_name = $dbParser->parseExpression($condition->attrs->column);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue