diff options
author | Jamie Matthews <[email protected]> | 2010-02-11 00:30:28 +0000 |
---|---|---|
committer | Jamie Matthews <[email protected]> | 2010-02-11 00:30:28 +0000 |
commit | 5afc001d3e01cb7910b71cfaa95b0113358b1c1e (patch) | |
tree | 860d258cd175c371147d3fc44d30f95aca674f90 /idiorm.php | |
parent | f2f346f6729d3d4fc252d56fb3403fbc461c214b (diff) |
Added LIMIT and OFFSET, added more documentation
Diffstat (limited to 'idiorm.php')
-rw-r--r-- | idiorm.php | 34 |
1 files changed, 34 insertions, 0 deletions
@@ -97,6 +97,12 @@ // Array of WHERE clauses private $where = array(); + // LIMIT + private $limit = null; + + // OFFSET + private $offset = null; + // The data for a hydrated instance of the class private $data = array(); @@ -267,6 +273,22 @@ } /** + * Add a LIMIT to the query + */ + public function limit($limit) { + $this->limit = $limit; + return $this; + } + + /** + * Add an OFFSET to the query + */ + public function offset($offset) { + $this->offset = $offset; + return $this; + } + + /** * Build a SELECT statement based on the clauses that have * been passed to this instance by chaining method calls. */ @@ -295,6 +317,18 @@ } } + // Add LIMIT if present + if (!is_null($this->limit)) { + $query[] = "LIMIT ?"; + $this->values[] = $this->limit; + } + + // Add OFFSET if present + if (!is_null($this->offset)) { + $query[] = "OFFSET ?"; + $this->values[] = $this->offset; + } + return join(" ", $query); } |