lithium\data\model\Query::offset PHP Method

offset() public method

Set and get method for query's offset, i.e. which records to get
public offset ( integer | null $offset = null ) : integer | lithium\data\Query
$offset integer | null
return integer | lithium\data\Query
    public function offset($offset = null)
    {
        if ($offset !== null) {
            $this->_config['offset'] = (int) $offset;
            return $this;
        }
        return $this->_config['offset'];
    }

Usage Example

Example #1
0
 public function testPagination()
 {
     $query = new Query(array('limit' => 5, 'page' => 1));
     $this->assertEqual(0, $query->offset());
     $query = new Query(array('limit' => 5, 'page' => 2));
     $this->assertEqual(5, $query->offset());
     $query->page(1);
     $this->assertEqual(0, $query->offset());
 }
All Usage Examples Of lithium\data\model\Query::offset