Refactor the query->get() method.
This commit is contained in:
parent
3d30f9f855
commit
22676ccee0
|
@ -524,6 +524,22 @@ public function get($columns = array('*'))
|
|||
$this->select($columns);
|
||||
}
|
||||
|
||||
$results = $this->connection->query($this->compile_select(), $this->bindings);
|
||||
|
||||
// Reset the SELECT clause so more queries can be performed using the same instance.
|
||||
// This is helpful for getting aggregates and then getting actual results.
|
||||
$this->select = null;
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compile the query into a SQL SELECT statement.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function compile_select()
|
||||
{
|
||||
$sql = $this->select.' '.$this->from.' '.$this->where;
|
||||
|
||||
if (count($this->orderings) > 0)
|
||||
|
@ -541,13 +557,7 @@ public function get($columns = array('*'))
|
|||
$sql .= ' OFFSET '.$this->offset;
|
||||
}
|
||||
|
||||
$results = $this->connection->query($sql, $this->bindings);
|
||||
|
||||
// Reset the SELECT clause so more queries can be performed using the same instance.
|
||||
// This is helpful for getting aggregates and then getting actual results.
|
||||
$this->select = null;
|
||||
|
||||
return $results;
|
||||
return $sql;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -586,7 +596,7 @@ public function insert_get_id($values)
|
|||
}
|
||||
|
||||
/**
|
||||
* Compile an SQL INSERT statement.
|
||||
* Compile the query into a SQL INSERT statement.
|
||||
*
|
||||
* @param array $values
|
||||
* @return string
|
||||
|
|
Loading…
Reference in New Issue