/** * @param Query $query */ public function __construct(Query $query) { $this->query = $query; $this->models = []; $this->start = $query->getStart(); $this->limit = $query->getLimit(); $this->pointer = $this->start; $sort = $query->getSort(); if (empty($sort)) { $model = $query->getModel(); $idProperties = $model::getIDProperties(); foreach ($idProperties as &$property) { $property .= ' asc'; } $query->sort(implode(',', $idProperties)); } }
/** * Build SQL LIMIT clause * @param Query $query * @return string */ protected function buildLimitClause(Query $query) { if ($limitClause = $query->getLimit()) { return "\nLIMIT " . $limitClause[1] . ', ' . $limitClause[0]; } else { return ''; } }
public function testLimit() { $query = new Query(); $query->limit(10); $this->assertEquals(10, $query->getLimit()); }