public function toDialectString(Dialect $dialect) { if ($this->where) { $deleteStr = 'DELETE FROM ' . $dialect->quoteTable($this->table) . parent::toDialectString($dialect); $this->checkReturning($dialect); if (empty($this->returning)) { return $deleteStr; } else { $query = $deleteStr . ' RETURNING ' . $this->toDialectStringReturning($dialect); return $query; } } else { throw new WrongArgumentException("leave '{$this->table}' table alone in peace, bastard"); } }
public function toDialectString(Dialect $dialect) { $fieldList = []; foreach ($this->fields as $field) { $fieldList[] = $this->toDialectStringField($field, $dialect); } $query = 'SELECT '; if ($this->distinct) { $query .= 'DISTINCT '; if ($this->distinctFields) { $distinctFieldsList = []; foreach ($this->distinctFields as $field) { $distinctFieldsList[] = $this->toDialectStringField($field, $dialect); } $query .= 'ON ('; $query .= implode(', ', $distinctFieldsList); $query .= ') '; } } $query .= implode(', ', $fieldList); $query .= $this->joiner->toDialectString($dialect); // WHERE $query .= parent::toDialectString($dialect); if ($this->group) { $groupList = []; foreach ($this->group as $group) { $groupList[] = $group->toDialectString($dialect); } if ($groupList) { $query .= ' GROUP BY ' . implode(', ', $groupList); } } if ($this->having) { $query .= ' HAVING ' . $this->having->toDialectString($dialect); } if ($this->order->getCount()) { $query .= ' ORDER BY ' . $this->order->toDialectString($dialect); } if ($this->limit) { $query .= ' LIMIT ' . $this->limit; } if ($this->offset) { $query .= ' OFFSET ' . $this->offset; } return $query; }
public function toDialectString(Dialect $dialect) { $this->checkReturning($dialect); if (empty($this->returning)) { return parent::toDialectString($dialect); } $query = parent::toDialectString($dialect) . ' RETURNING ' . $this->toDialectStringReturning($dialect); return $query; }