Exemplo n.º 1
0
 /**
  * @param   SQLStatement $update
  * 
  * @return  string
  */
 public function update(SQLStatement $update) : string
 {
     $joins = $this->handleJoins($update->getJoins());
     $tables = $update->getTables();
     if ($joins !== '') {
         $joins = ' FROM ' . $this->handleTables($tables) . ' ' . $joins;
         $tables = array_values($tables);
     }
     $sql = 'UPDATE ';
     $sql .= $this->handleTables($tables);
     $sql .= $this->handleSetColumns($update->getColumns());
     $sql .= $joins;
     $sql .= $this->handleWheres($update->getWheres());
     return $sql;
 }
Exemplo n.º 2
0
 /**
  * Compiles a SELECT query.
  *
  * @access  public
  * @param   SQLStatement    $select
  * @return  array
  */
 public function select(SQLStatement $select)
 {
     $sql = $select->getDistinct() ? '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->getJoins());
     $sql .= $this->handleWheres($select->getWheres());
     $sql .= $this->handleGroupings($select->getGroupBy());
     $sql .= $this->handleOrderings($select->getOrder());
     $sql .= $this->handleHavings($select->getHaving());
     $sql .= $this->handleOffset($select->getOffset(), $select->getLimit());
     $sql .= $this->handleLimit($select->getLimit(), $select->getOffset());
     return $sql;
 }
Exemplo n.º 3
0
 /**
  * Returns the SQL for a delete statement
  *
  * @param SQLStatement $delete
  * @return string
  */
 public function delete(SQLStatement $delete) : string
 {
     $sql = 'DELETE ' . $this->handleTables($delete->getTables());
     $sql .= $sql === 'DELETE ' ? 'FROM ' : ' FROM ';
     $sql .= $this->handleTables($delete->getFrom());
     $sql .= $this->handleJoins($delete->getJoins());
     $sql .= $this->handleWheres($delete->getWheres());
     return $sql;
 }