Example #1
0
 /**
  * @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));
     }
 }
Example #2
0
 /**
  * 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 '';
     }
 }
Example #3
0
 public function testLimit()
 {
     $query = new Query();
     $query->limit(10);
     $this->assertEquals(10, $query->getLimit());
 }