Limit, Order By
This commit is contained in:
@@ -8,6 +8,10 @@ class Select extends Query {
|
||||
private $tables;
|
||||
private $conditions;
|
||||
private $joins;
|
||||
private $orderColumns;
|
||||
private $sortAscending;
|
||||
private $limit;
|
||||
private $offset;
|
||||
|
||||
public function __construct($sql, ...$columns) {
|
||||
parent::__construct($sql);
|
||||
@@ -15,6 +19,10 @@ class Select extends Query {
|
||||
$this->tables = array();
|
||||
$this->conditions = array();
|
||||
$this->joins = array();
|
||||
$this->orderColumns = array();
|
||||
$this->limit = 0;
|
||||
$this->offset = 0;
|
||||
$this->sortAscending = true;
|
||||
}
|
||||
|
||||
public function from(...$tables) {
|
||||
@@ -37,6 +45,31 @@ class Select extends Query {
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function orderBy(...$columns) {
|
||||
$this->orderColumns = $columns;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function ascending() {
|
||||
$this->ascending = true;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function descending() {
|
||||
$this->ascending = false;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function limit($limit) {
|
||||
$this->limit = $limit;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function offset($offset) {
|
||||
$this->offset = $offset;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function execute() {
|
||||
return $this->sql->executeSelect($this);
|
||||
}
|
||||
@@ -45,6 +78,11 @@ class Select extends Query {
|
||||
public function getTables() { return $this->tables; }
|
||||
public function getConditions() { return $this->conditions; }
|
||||
public function getJoins() { return $this->joins; }
|
||||
public function isOrderedAscending() { return $this->ascending; }
|
||||
public function getOrderBy() { return $this->orderColumns; }
|
||||
public function getLimit() { return $this->limit; }
|
||||
public function getOffset() { return $this->offset; }
|
||||
|
||||
};
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user