Support HAVING in XML queries

GROUP BY에 사용되는 <groups> 태그 안에 <having> 태그를 넣을 수 있습니다.
문법은 <conditions> 부분에 적용되는 것과 같습니다.

<query id="queryId" action="select">
    ...
    <groups>
        <group column="document_srl" />
        <having>
            <condition operation="more" column="document_srl" var="myvar" default="0" />
        </having>
    </groups>
    ...
</query>

결과: SELECT ... GROUP BY document_srl HAVING document_srl >= 0
This commit is contained in:
Kijin Sung 2018-07-03 15:40:52 +09:00
parent 2b5cded376
commit 20fa55a3fc
3 changed files with 89 additions and 6 deletions

View file

@ -71,6 +71,12 @@ class QueryTag
*/
var $groups;
/**
* Having in xml tags
* @var object
*/
var $having;
/**
* Navigation in xml tags
* @var object
@ -303,7 +309,8 @@ class QueryTag
$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->setGroups(' . $this->groups->toString() . ');' . PHP_EOL;
$buff .= '$query->setHaving(' . $this->having->toString() . ');' . PHP_EOL;
$buff .= '$query->setOrder(' . $this->navigation->getOrderByString() . ');' . PHP_EOL;
$buff .= '$query->setLimit(' . $this->navigation->getLimitString() . ');' . PHP_EOL;
@ -340,12 +347,16 @@ class QueryTag
{
if($this->query->groups)
{
return $this->groups = new GroupsTag($this->query->groups->group);
$this->groups = new GroupsTag($this->query->groups->group);
$this->having = new ConditionsTag($this->query->groups->having);
}
else
{
return $this->groups = new GroupsTag(NULL);
}
$this->groups = new GroupsTag(NULL);
$this->having = new ConditionsTag(array());
}
return $this->groups;
}
function getNavigation()
@ -385,7 +396,8 @@ class QueryTag
$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->conditions->getArguments());
$arguments = array_merge($arguments, $this->having->getArguments());
$arguments = array_merge($arguments, $this->navigation->getArguments());
return $arguments;
}