コード例 #1
0
 /**
  * Returns SQL query.
  * @return string
  */
 public function buildSelectQuery()
 {
     $join = $this->buildJoins(implode(',', $this->conditions), TRUE);
     $join += $this->buildJoins(implode(',', $this->select) . ",{$this->group},{$this->having}," . implode(',', $this->order));
     $prefix = $join ? "{$this->delimitedTable}." : '';
     if ($this->select) {
         $cols = $this->tryDelimite($this->removeExtraTables(implode(', ', $this->select)));
     } elseif ($prevAccessed = $this->selection->getPreviousAccessed()) {
         $cols = array_map(array($this->connection->getSupplementalDriver(), 'delimite'), array_keys(array_filter($prevAccessed)));
         $cols = $prefix . implode(', ' . $prefix, $cols);
     } else {
         $cols = $prefix . '*';
     }
     return "SELECT{$this->buildTopClause()} {$cols} FROM {$this->delimitedTable}" . implode($join) . $this->buildConditions();
 }