mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-09 12:02:24 +09:00
Implement the COUNT(*) query for pagination
This commit is contained in:
parent
7e96affa1a
commit
84a7b915b7
2 changed files with 119 additions and 14 deletions
|
|
@ -19,6 +19,7 @@ class Query extends VariableBase
|
|||
public $navigation = null;
|
||||
public $select_distinct = false;
|
||||
public $update_duplicate = false;
|
||||
public $requires_pagination = false;
|
||||
|
||||
/**
|
||||
* Attributes for subqueries in the <tables> or <columns> section.
|
||||
|
|
@ -95,6 +96,16 @@ class Query extends VariableBase
|
|||
return $this->_params;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if this query requires pagination.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function requiresPagination(): bool
|
||||
{
|
||||
return $this->requires_pagination;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a SELECT query string.
|
||||
*
|
||||
|
|
@ -514,9 +525,19 @@ class Query extends VariableBase
|
|||
{
|
||||
list($is_expression, $offset) = $navigation->offset->getValue($this->_args);
|
||||
}
|
||||
|
||||
// If page is available, set the offset and require pagination for this query.
|
||||
if ($page > 0)
|
||||
{
|
||||
$offset = $list_count * ($page - 1);
|
||||
if ($this->type === 'SELECT')
|
||||
{
|
||||
$this->requires_pagination = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
// Return the LIMIT/OFFSET clause.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue