Esempio n. 1
0
 protected function visitSelect(Select $select)
 {
     $this->selectCount++;
     $columns = array();
     foreach ($select->getColumns() as $c) {
         $columns[] = $this->process($c);
     }
     $froms = array();
     foreach ($select->getFroms() as $f) {
         $froms[] = $this->process($f);
     }
     $sql = 'SELECT ' . ($select->distinct ? 'DISTINCT ' : '') . implode(', ', $columns) . ' FROM ' . implode(', ', $froms);
     $where = $select->whereClause;
     $orderBy = $select->orderByClause;
     $limit = $this->getLimitClause($select->offset, $select->limit);
     if ($where !== null) {
         $sql .= ' WHERE ' . $this->process($where);
     }
     if ($orderBy !== null) {
         $sql .= ' ORDER BY ' . $this->process($orderBy);
     }
     if (!empty($limit)) {
         $sql .= $limit;
     }
     if ($this->isSubquery()) {
         $sql = '(' . $sql . ')';
     }
     $this->selectCount--;
     return $sql;
 }