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()); }
/** * Returns a LIMIT statement from the given limit and the offset of the context object. * * @param integer $limit * @param \lithium\data\model\Query $context * @return string */ public function limit($limit, $context) { if (!$limit) { return; } if ($offset = $context->offset() ?: '') { $offset = " OFFSET {$offset}"; } return "LIMIT {$limit}{$offset}"; }