Skip to content

Commit

Permalink
Add support for limit in update and delete queries
Browse files Browse the repository at this point in the history
  • Loading branch information
nechutny committed Aug 18, 2016
1 parent 05aa911 commit 913d3d4
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/Database/Table/SqlBuilder.php
Expand Up @@ -120,19 +120,23 @@ public function buildInsertQuery()

public function buildUpdateQuery()
{
$query = "UPDATE {$this->delimitedTable} SET ?set" . $this->tryDelimite($this->buildConditions());
if ($this->limit !== NULL || $this->offset) {
throw new Nette\NotSupportedException('LIMIT clause is not supported in UPDATE query.');
$this->driver->applyLimit($query, $this->limit, $this->offset);
}
return "UPDATE {$this->delimitedTable} SET ?set" . $this->tryDelimite($this->buildConditions());

return $query;
}


public function buildDeleteQuery()
{
$query = "DELETE FROM {$this->delimitedTable}" . $this->tryDelimite($this->buildConditions());
if ($this->limit !== NULL || $this->offset) {
throw new Nette\NotSupportedException('LIMIT clause is not supported in DELETE query.');
$this->driver->applyLimit($query, $this->limit, $this->offset);
}
return "DELETE FROM {$this->delimitedTable}" . $this->tryDelimite($this->buildConditions());

return $query;
}


Expand Down

0 comments on commit 913d3d4

Please sign in to comment.