Commit db391b80 authored by Taylor Otwell's avatar Taylor Otwell

Refactor the database query class.

parent 64fb09a8
...@@ -527,20 +527,11 @@ class Query { ...@@ -527,20 +527,11 @@ class Query {
$sql = $this->select.' '.$this->from.' '.$this->where; $sql = $this->select.' '.$this->from.' '.$this->where;
if (count($this->orderings) > 0) if (count($this->orderings) > 0) $sql .= ' ORDER BY '.implode(', ', $this->orderings);
{
$sql .= ' ORDER BY '.implode(', ', $this->orderings);
}
if ( ! is_null($this->limit)) if ( ! is_null($this->limit)) $sql .= ' LIMIT '.$this->limit;
{
$sql .= ' LIMIT '.$this->limit;
}
if ( ! is_null($this->offset)) if ( ! is_null($this->offset)) $sql .= ' OFFSET '.$this->offset;
{
$sql .= ' OFFSET '.$this->offset;
}
$results = $this->connection->query($sql, $this->bindings); $results = $this->connection->query($sql, $this->bindings);
...@@ -689,13 +680,11 @@ class Query { ...@@ -689,13 +680,11 @@ class Query {
*/ */
public function __call($method, $parameters) public function __call($method, $parameters)
{ {
// Dynamically handle the addition of dynamic where clauses.
if (strpos($method, 'where_') === 0) if (strpos($method, 'where_') === 0)
{ {
return $this->dynamic_where($method, $parameters, $this); 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'))) if (in_array($method, array('count', 'min', 'max', 'avg', 'sum')))
{ {
return ($method == 'count') ? $this->aggregate(strtoupper($method), '*') : $this->aggregate(strtoupper($method), $parameters[0]); return ($method == 'count') ? $this->aggregate(strtoupper($method), '*') : $this->aggregate(strtoupper($method), $parameters[0]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment