Exemplo n.º 1
0
 /**
  * Build a select query
  *
  * @access public
  * @return string
  */
 public function buildSelectQuery()
 {
     if (empty($this->sqlSelect)) {
         $this->columns = $this->db->escapeIdentifierList($this->columns);
         $this->sqlSelect = ($this->distinct ? 'DISTINCT ' : '') . (empty($this->columns) ? '*' : implode(', ', $this->columns));
     }
     $this->groupBy = $this->db->escapeIdentifierList($this->groupBy);
     return trim(sprintf('SELECT %s FROM %s %s %s %s %s %s %s', $this->sqlSelect, $this->db->escapeIdentifier($this->name), implode(' ', $this->joins), $this->condition->build(), empty($this->groupBy) ? '' : 'GROUP BY ' . implode(', ', $this->groupBy), $this->sqlOrder, $this->sqlLimit, $this->sqlOffset));
 }