/** * Parses the given statement. * @return string The SQL statement */ public function parse() { $where = $order = $group = $limit = $q = ''; $source = $this->parseSource(); if ($this->stmt->getConditions()) { $where = $this->parseWhere(); } if ($this->stmt instanceof Result && $this->stmt->getGrouping()) { $group = $this->parseGrouping(); } if ($this->stmt->getSorting()) { $order = $this->parseSorting(); } $this->clauses = array($source, $where, $group, $order); if ($this->stmt->getType() === Manager::STMT_SELECT) { $q = $this->parseSelectStmt(); } elseif ($this->stmt->getType() === Manager::STMT_INSERT) { $q = $this->parseInsertStmt(); } elseif ($this->stmt->getType() === Manager::STMT_UPDATE) { $q = $this->parseUpdateStmt(); } elseif ($this->stmt->getType() === Manager::STMT_DELETE) { $q = $this->parseDeleteStmt(); } return trim($q); }