From 277be848534d890c62d60e5cf485e35b9a50b25b Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 2 Aug 2011 08:49:19 -0500 Subject: [PATCH] Added where_id and or_where_id to the query builder. --- system/db/query.php | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/system/db/query.php b/system/db/query.php index a4a2cfa1..fc1b1947 100644 --- a/system/db/query.php +++ b/system/db/query.php @@ -2,6 +2,7 @@ use System\Str; use System\Config; +use System\Paginator; class Query { @@ -238,6 +239,30 @@ class Query { return $this->where($column, $operator, $value, 'OR'); } + /** + * Add a where condition for the primary key to the query. + * This is simply a short-cut method for convenience. + * + * @param mixed $value + * @return Query + */ + public function where_id($value) + { + return $this->where('id', '=', $value); + } + + /** + * Add an or where condition for the primary key to the query. + * This is simply a short-cut method for convenience. + * + * @param mixed $value + * @return Query + */ + public function or_where_id($value) + { + return $this->or_where('id', '=', $value); + } + /** * Add a where in condition to the query. * @@ -473,7 +498,7 @@ class Query { $this->select($columns); - return \System\Paginator::make($this->for_page(\System\Paginator::page($total, $per_page), $per_page)->get(), $total, $per_page); + return Paginator::make($this->for_page(Paginator::page($total, $per_page), $per_page)->get(), $total, $per_page); } /**