From db391b8090a6122a127c1d1b883aeb5dacf5e581 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Mon, 8 Aug 2011 10:24:23 -0500 Subject: [PATCH] Refactor the database query class. --- system/db/query.php | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/system/db/query.php b/system/db/query.php index fc1b1947..2be38e45 100644 --- a/system/db/query.php +++ b/system/db/query.php @@ -527,20 +527,11 @@ class Query { $sql = $this->select.' '.$this->from.' '.$this->where; - if (count($this->orderings) > 0) - { - $sql .= ' ORDER BY '.implode(', ', $this->orderings); - } + if (count($this->orderings) > 0) $sql .= ' ORDER BY '.implode(', ', $this->orderings); - if ( ! is_null($this->limit)) - { - $sql .= ' LIMIT '.$this->limit; - } + if ( ! is_null($this->limit)) $sql .= ' LIMIT '.$this->limit; - if ( ! is_null($this->offset)) - { - $sql .= ' OFFSET '.$this->offset; - } + if ( ! is_null($this->offset)) $sql .= ' OFFSET '.$this->offset; $results = $this->connection->query($sql, $this->bindings); @@ -689,13 +680,11 @@ class Query { */ public function __call($method, $parameters) { - // Dynamically handle the addition of dynamic where clauses. if (strpos($method, 'where_') === 0) { return $this->dynamic_where($method, $parameters, $this); } - // Dynamically handle calls to any of the aggregate query functions. if (in_array($method, array('count', 'min', 'max', 'avg', 'sum'))) { return ($method == 'count') ? $this->aggregate(strtoupper($method), '*') : $this->aggregate(strtoupper($method), $parameters[0]);