Changeset 3540

Show
Ignore:
Timestamp:
01/17/08 15:33:08 (18 months ago)
Author:
guilhermeblanco
Message:

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

Files:
3 modified

Legend:

Unmodified
Added
Removed
  • branches/0.10/lib/Doctrine/Pager.php

    r3539 r3540  
    108108        // retrieve the number of items found 
    109109        $count = $this->getCountQuery()->count($this->getCountQueryParams($params)); 
     110 
    110111        $this->_setNumResults($count); 
    111  
    112         $this->_setExecuted(true); 
     112        $this->_setExecuted(true); // _adjustOffset relies of _executed equals true = getNumResults() 
    113113 
    114114        $this->_adjustOffset(); 
     
    125125    protected function _adjustOffset() 
    126126    { 
    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()); 
    139137    } 
    140138 
  • branches/0.9/lib/Doctrine/Pager.php

    r3539 r3540  
    108108        // retrieve the number of items found 
    109109        $count = $this->getCountQuery()->count($this->getCountQueryParams($params)); 
     110 
    110111        $this->_setNumResults($count); 
    111  
    112         $this->_setExecuted(true); 
     112        $this->_setExecuted(true); // _adjustOffset relies of _executed equals true = getNumResults() 
    113113 
    114114        $this->_adjustOffset(); 
     
    125125    protected function _adjustOffset() 
    126126    { 
    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()); 
    139137    } 
    140138 
  • trunk/lib/Doctrine/Pager.php

    r3539 r3540  
    108108        // retrieve the number of items found 
    109109        $count = $this->getCountQuery()->count($this->getCountQueryParams($params)); 
     110 
    110111        $this->_setNumResults($count); 
    111  
    112         $this->_setExecuted(true); 
     112        $this->_setExecuted(true); // _adjustOffset relies of _executed equals true = getNumResults() 
    113113 
    114114        $this->_adjustOffset(); 
     
    125125    protected function _adjustOffset() 
    126126    { 
    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()); 
    139137    } 
    140138