Changeset 3540
- Timestamp:
- 01/17/08 15:33:08 (18 months ago)
- Files:
-
- 3 modified
-
branches/0.10/lib/Doctrine/Pager.php (modified) (2 diffs)
-
branches/0.9/lib/Doctrine/Pager.php (modified) (2 diffs)
-
trunk/lib/Doctrine/Pager.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/0.10/lib/Doctrine/Pager.php
r3539 r3540 108 108 // retrieve the number of items found 109 109 $count = $this->getCountQuery()->count($this->getCountQueryParams($params)); 110 110 111 $this->_setNumResults($count); 111 112 $this->_setExecuted(true); 112 $this->_setExecuted(true); // _adjustOffset relies of _executed equals true = getNumResults() 113 113 114 114 $this->_adjustOffset(); … … 125 125 protected function _adjustOffset() 126 126 { 127 if (!$this->getExecuted()) { 128 // Define new total of pages 129 $this->_setLastPage( 130 max(1, ceil($this->getNumResults() / $this->getMaxPerPage())) 131 ); 132 $offset = ($this->getPage() - 1) * $this->getMaxPerPage(); 133 134 // Assign new offset and limit to Doctrine_Query object 135 $p = $this->getQuery(); 136 $p->offset($offset); 137 $p->limit($this->getMaxPerPage()); 138 } 127 // Define new total of pages 128 $this->_setLastPage( 129 max(1, ceil($this->getNumResults() / $this->getMaxPerPage())) 130 ); 131 $offset = ($this->getPage() - 1) * $this->getMaxPerPage(); 132 133 // Assign new offset and limit to Doctrine_Query object 134 $p = $this->getQuery(); 135 $p->offset($offset); 136 $p->limit($this->getMaxPerPage()); 139 137 } 140 138 -
branches/0.9/lib/Doctrine/Pager.php
r3539 r3540 108 108 // retrieve the number of items found 109 109 $count = $this->getCountQuery()->count($this->getCountQueryParams($params)); 110 110 111 $this->_setNumResults($count); 111 112 $this->_setExecuted(true); 112 $this->_setExecuted(true); // _adjustOffset relies of _executed equals true = getNumResults() 113 113 114 114 $this->_adjustOffset(); … … 125 125 protected function _adjustOffset() 126 126 { 127 if (!$this->getExecuted()) { 128 // Define new total of pages 129 $this->_setLastPage( 130 max(1, ceil($this->getNumResults() / $this->getMaxPerPage())) 131 ); 132 $offset = ($this->getPage() - 1) * $this->getMaxPerPage(); 133 134 // Assign new offset and limit to Doctrine_Query object 135 $p = $this->getQuery(); 136 $p->offset($offset); 137 $p->limit($this->getMaxPerPage()); 138 } 127 // Define new total of pages 128 $this->_setLastPage( 129 max(1, ceil($this->getNumResults() / $this->getMaxPerPage())) 130 ); 131 $offset = ($this->getPage() - 1) * $this->getMaxPerPage(); 132 133 // Assign new offset and limit to Doctrine_Query object 134 $p = $this->getQuery(); 135 $p->offset($offset); 136 $p->limit($this->getMaxPerPage()); 139 137 } 140 138 -
trunk/lib/Doctrine/Pager.php
r3539 r3540 108 108 // retrieve the number of items found 109 109 $count = $this->getCountQuery()->count($this->getCountQueryParams($params)); 110 110 111 $this->_setNumResults($count); 111 112 $this->_setExecuted(true); 112 $this->_setExecuted(true); // _adjustOffset relies of _executed equals true = getNumResults() 113 113 114 114 $this->_adjustOffset(); … … 125 125 protected function _adjustOffset() 126 126 { 127 if (!$this->getExecuted()) { 128 // Define new total of pages 129 $this->_setLastPage( 130 max(1, ceil($this->getNumResults() / $this->getMaxPerPage())) 131 ); 132 $offset = ($this->getPage() - 1) * $this->getMaxPerPage(); 133 134 // Assign new offset and limit to Doctrine_Query object 135 $p = $this->getQuery(); 136 $p->offset($offset); 137 $p->limit($this->getMaxPerPage()); 138 } 127 // Define new total of pages 128 $this->_setLastPage( 129 max(1, ceil($this->getNumResults() / $this->getMaxPerPage())) 130 ); 131 $offset = ($this->getPage() - 1) * $this->getMaxPerPage(); 132 133 // Assign new offset and limit to Doctrine_Query object 134 $p = $this->getQuery(); 135 $p->offset($offset); 136 $p->limit($this->getMaxPerPage()); 139 137 } 140 138