/**
  * @param Delete $delete
  *
  * @return string
  */
 public function write(Delete $delete)
 {
     $table = $this->writer->writeTable($delete->getTable());
     $parts = array("DELETE FROM {$table}");
     AbstractBaseWriter::writeWhereCondition($delete, $this->writer, $this->placeholderWriter, $parts);
     AbstractBaseWriter::writeLimitCondition($delete, $this->placeholderWriter, $parts);
     $comment = AbstractBaseWriter::writeQueryComment($delete);
     return $comment . implode(" ", $parts);
 }
Esempio n. 2
0
 /**
  * @param Insert $insert
  *
  * @throws QueryException
  *
  * @return string
  */
 public function write(Insert $insert)
 {
     $columns = $insert->getColumns();
     if (empty($columns)) {
         throw new QueryException('No columns were defined for the current schema.');
     }
     $columns = $this->writeQueryColumns($columns);
     $values = $this->writeQueryValues($insert->getValues());
     $table = $this->writer->writeTable($insert->getTable());
     $comment = AbstractBaseWriter::writeQueryComment($insert);
     return $comment . "INSERT INTO {$table} ({$columns}) VALUES ({$values})";
 }
 /**
  * @param Update $update
  *
  * @throws QueryException
  * @return string
  */
 public function write(Update $update)
 {
     $values = $update->getValues();
     if (empty($values)) {
         throw new QueryException('No values to update in Update query.');
     }
     $parts = array("UPDATE " . $this->writer->writeTable($update->getTable()) . " SET ", $this->writeUpdateValues($update));
     AbstractBaseWriter::writeWhereCondition($update, $this->writer, $this->placeholderWriter, $parts);
     AbstractBaseWriter::writeLimitCondition($update, $this->placeholderWriter, $parts);
     $comment = AbstractBaseWriter::writeQueryComment($update);
     return $comment . implode(" ", $parts);
 }
 /**
  * @param Select $select
  *
  * @return string
  */
 protected function writeSelectQuery(Select $select)
 {
     $parts = ['SELECT'];
     if ($select->isDistinct()) {
         $parts[] = 'DISTINCT';
     }
     $this->writeSelectColumns($select, $parts);
     $this->writeSelectFrom($select, $parts);
     $this->writeSelectJoins($select, $parts);
     $this->writeSelectWhere($select, $parts);
     $this->writeSelectGroupBy($select, $parts);
     $this->writeSelectHaving($select, $parts);
     $this->writeSelectOrderBy($select, $parts);
     $this->writeSelectLimit($select, $parts);
     return AbstractBaseWriter::writeQueryComment($select) . implode(' ', \array_filter($parts));
 }
 /**
  * @param Select $select
  *
  * @return string
  */
 public function writeSelectQuery(Select $select)
 {
     $parts = array("SELECT");
     if ($select->isDistinct()) {
         $parts[] = "DISTINCT";
     }
     $this->writeSelectColumns($select, $parts);
     $this->writeSelectFrom($select, $parts);
     $this->writeSelectJoins($select, $parts);
     $this->writeSelectWhere($select, $parts);
     $this->writeSelectGroupBy($select, $parts);
     $this->writeSelectHaving($select, $parts);
     $this->writeSelectOrderBy($select, $parts);
     $this->writeSelectLimit($select, $parts);
     return AbstractBaseWriter::writeQueryComment($select) . implode(" ", array_filter($parts));
 }