Zend Framework
1.12
|
Public Member Functions | |
__construct (Zend_Db_Select $select) | |
Constructor. | |
getCacheIdentifier () | |
Returns the cache identifier. | |
setRowCount ($rowCount) | |
Sets the total row count, either directly or through a supplied query. | |
getItems ($offset, $itemCountPerPage) | |
Returns an array of items for a page. | |
count () | |
Returns the total number of rows in the result set. | |
getCountSelect () | |
Get the COUNT select object for the provided query. | |
Public Attributes | |
const | ROW_COUNT_COLUMN = 'zend_paginator_row_count' |
Protected Attributes | |
$_countSelect = null | |
$_select = null | |
$_rowCount = null | |
$_cacheIdentifier = null | |
__construct | ( | Zend_Db_Select | $select | ) |
Constructor.
Zend_Db_Select | $select | The select query |
count | ( | ) |
Returns the total number of rows in the result set.
getCacheIdentifier | ( | ) |
Returns the cache identifier.
getCountSelect | ( | ) |
Get the COUNT select object for the provided query.
TODO: Have a look at queries that have both GROUP BY and DISTINCT specified. In that use-case I'm expecting problems when either GROUP BY or DISTINCT has one column.
We only need to generate a COUNT query once. It will not change for this instance.
If we're dealing with a UNION query, execute the UNION as a subquery to the COUNT query.
If there is more than one column AND it's a DISTINCT query, more than one group, or if the query has a HAVING clause, then take the original query and use it as a subquery os the COUNT query.
If the original query had a GROUP BY or a DISTINCT part and only one column was specified, create a COUNT(DISTINCT ) query instead of a regular COUNT query.
Create the COUNT part of the query
getItems | ( | $offset, | |
$itemCountPerPage | |||
) |
Returns an array of items for a page.
integer | $offset | Page offset |
integer | $itemCountPerPage | Number of items per page |
Implements Zend_Paginator_Adapter_Interface.
setRowCount | ( | $rowCount | ) |
Sets the total row count, either directly or through a supplied query.
Without setting this, getPages() selects the count as a subquery (SELECT COUNT ... FROM (SELECT ...)). While this yields an accurate count even with queries containing clauses like LIMIT, it can be slow in some circumstances. For example, in MySQL, subqueries are generally slow when using the InnoDB storage engine. Users are therefore encouraged to profile their queries to find the solution that best meets their needs.
Zend_Db_Select | integer | $totalRowCount | Total row count integer or query |
Zend_Paginator_Exception |
|
protected |
|
protected |
|
protected |
|
protected |
const ROW_COUNT_COLUMN = 'zend_paginator_row_count' |