public function buildQuery(Query $query)
{
$this->_query = $query;
$sql = '';
if ($query->type == QueryType::$UPDATE) {
$sql .= $this->update();
$sql .= $this->where();
} elseif ($query->type == QueryType::$INSERT) {
$sql .= $this->insert();
} elseif ($query->type == QueryType::$DELETE) {
$sql .= $this->delete();
$sql .= $this->from();
$sql .= $this->using();
$sql .= $this->whereWithUsing();
} elseif ($query->type == QueryType::$COUNT) {
$sql .= $this->select();
$sql .= $this->from();
$sql .= $this->join();
$sql .= $this->where();
} else {
$sql .= $this->select();
$sql .= $this->from();
$sql .= $this->join();
$sql .= $this->where();
$sql .= $this->groupBy();
$sql .= $this->order();
$sql .= $this->limit();
$sql .= $this->offset();
$sql .= $this->lockForUpdate();
}
return rtrim($sql);
}