1
0
mirror of synced 2024-12-13 14:56:01 +03:00

Fixed _adjustOffset in order to get it working after previous change in Pager

This commit is contained in:
guilhermeblanco 2008-01-17 15:33:08 +00:00
parent 78edfd59a6
commit 99d026b894

View File

@ -107,9 +107,9 @@ class Doctrine_Pager
{
// retrieve the number of items found
$count = $this->getCountQuery()->count($this->getCountQueryParams($params));
$this->_setNumResults($count);
$this->_setExecuted(true);
$this->_setNumResults($count);
$this->_setExecuted(true); // _adjustOffset relies of _executed equals true = getNumResults()
$this->_adjustOffset();
}
@ -124,18 +124,16 @@ class Doctrine_Pager
*/
protected function _adjustOffset()
{
if (!$this->getExecuted()) {
// Define new total of pages
$this->_setLastPage(
max(1, ceil($this->getNumResults() / $this->getMaxPerPage()))
);
$offset = ($this->getPage() - 1) * $this->getMaxPerPage();
// Define new total of pages
$this->_setLastPage(
max(1, ceil($this->getNumResults() / $this->getMaxPerPage()))
);
$offset = ($this->getPage() - 1) * $this->getMaxPerPage();
// Assign new offset and limit to Doctrine_Query object
$p = $this->getQuery();
$p->offset($offset);
$p->limit($this->getMaxPerPage());
}
// Assign new offset and limit to Doctrine_Query object
$p = $this->getQuery();
$p->offset($offset);
$p->limit($this->getMaxPerPage());
}