JamesMoss\Flywheel\Query::limit PHP Method

limit() public method

Set a limit on the number of documents returned. An offset from 0 can also be specified.
public limit ( integer $count, integer $offset ) : Query
$count integer The number of documents to return.
$offset integer The offset from which to return.
return Query The same instance of this class.
    public function limit($count, $offset = 0)
    {
        $this->limit = array((int) $count, (int) $offset);
        return $this;
    }

Usage Example

Ejemplo n.º 1
0
 public function testLimit()
 {
     $path = __DIR__ . '/fixtures/datastore/querytest';
     $config = new Config($path . '/');
     $repo = new Repository('countries', $config);
     $query = new Query($repo);
     $query->limit('10');
     $this->assertAttributeEquals(array(10, 0), 'limit', $query);
     $query->limit(5, 10);
     $this->assertAttributeEquals(array(5, 10), 'limit', $query);
     $query->limit(9, '11');
     $this->assertAttributeEquals(array(9, 11), 'limit', $query);
 }