mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-02 01:52:10 +09:00
Merge pull request #582 from kijin/pr/offset-query
XML 쿼리에서 LIMIT OFFSET을 직접 지정할 수 있도록 지원
This commit is contained in:
commit
4175535bc3
2 changed files with 24 additions and 3 deletions
|
|
@ -37,10 +37,11 @@ class Limit
|
|||
* constructor
|
||||
* @param int $list_count
|
||||
* @param int $page
|
||||
* @param int $page_count
|
||||
* @param int $page_count
|
||||
* @param int $offset
|
||||
* @return void
|
||||
*/
|
||||
function __construct($list_count, $page = NULL, $page_count = NULL)
|
||||
function __construct($list_count, $page = NULL, $page_count = NULL, $offset = NULL)
|
||||
{
|
||||
$this->list_count = $list_count;
|
||||
if($page)
|
||||
|
|
@ -50,6 +51,10 @@ class Limit
|
|||
$this->start = ($page_value - 1) * $list_count_value;
|
||||
$this->page_count = $page_count;
|
||||
$this->page = $page;
|
||||
}
|
||||
elseif($offset)
|
||||
{
|
||||
$this->start = $offset->getValue();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -81,7 +86,7 @@ class Limit
|
|||
|
||||
function toString()
|
||||
{
|
||||
if($this->page)
|
||||
if($this->page || $this->start)
|
||||
{
|
||||
return $this->start . ' , ' . $this->list_count->getValue();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,12 @@ class LimitTag
|
|||
*/
|
||||
var $list_count;
|
||||
|
||||
/**
|
||||
* QueryArgument object
|
||||
* @var QueryArgument
|
||||
*/
|
||||
var $offset;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
* @param object $index
|
||||
|
|
@ -58,6 +64,12 @@ class LimitTag
|
|||
$index->list_count->attrs->default = 0;
|
||||
$this->list_count = new QueryArgument($index->list_count);
|
||||
$this->arguments[] = $this->list_count;
|
||||
|
||||
if(isset($index->offset) && isset($index->offset->attrs))
|
||||
{
|
||||
$this->offset = new QueryArgument($index->offset);
|
||||
$this->arguments[] = $this->offset;
|
||||
}
|
||||
}
|
||||
|
||||
function toString()
|
||||
|
|
@ -66,6 +78,10 @@ class LimitTag
|
|||
{
|
||||
return sprintf('new Limit(${\'%s_argument\'}, ${\'%s_argument\'}, ${\'%s_argument\'})', $this->list_count->getArgumentName(), $this->page->getArgumentName(), $this->page_count->getArgumentName());
|
||||
}
|
||||
elseif($this->offset)
|
||||
{
|
||||
return sprintf('new Limit(${\'%s_argument\'}, NULL, NULL, ${\'%s_argument\'})', $this->list_count->getArgumentName(), $this->offset->getArgumentName());
|
||||
}
|
||||
else
|
||||
{
|
||||
return sprintf('new Limit(${\'%s_argument\'})', $this->list_count->getArgumentName());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue