Example #1
0
 /**
  * Compiles a SELECT query.
  *
  * @access  public
  * @param   \Opis\Database\SQL\SelectStatement    $select  Select object.
  * @return  array
  */
 public function select(SelectStatement $select)
 {
     $sql = $select->isDistinct() ? 'SELECT DISTINCT ' : 'SELECT ';
     $sql .= $this->handleColumns($select->getColumns());
     $sql .= $this->handleInto($select->getIntoTable(), $select->getIntoDatabase());
     $sql .= ' FROM ';
     $sql .= $this->handleTables($select->getTables());
     $sql .= $this->handleJoins($select->getJoinClauses());
     $sql .= $this->handleWheres($select->getWhereConditions());
     $sql .= $this->handleGroupings($select->getGroupClauses());
     $sql .= $this->handleOrderings($select->getOrderClauses());
     $sql .= $this->handleHavings($select->getHavingConditions());
     $sql .= $this->handleOffset($select->getOffset(), $select->getLimit());
     $sql .= $this->handleLimit($select->getLimit(), $select->getOffset());
     return $sql;
 }