Skip to content

Commit b816407

Browse files
nechutnydg
authored andcommitted
SqlBuilder: added support for limit in update and delete queries (#140)
1 parent aedf176 commit b816407

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/Database/Table/SqlBuilder.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,19 +120,23 @@ public function buildInsertQuery()
120120

121121
public function buildUpdateQuery()
122122
{
123+
$query = "UPDATE {$this->delimitedTable} SET ?set" . $this->tryDelimite($this->buildConditions());
123124
if ($this->limit !== NULL || $this->offset) {
124-
throw new Nette\NotSupportedException('LIMIT clause is not supported in UPDATE query.');
125+
$this->driver->applyLimit($query, $this->limit, $this->offset);
125126
}
126-
return "UPDATE {$this->delimitedTable} SET ?set" . $this->tryDelimite($this->buildConditions());
127+
128+
return $query;
127129
}
128130

129131

130132
public function buildDeleteQuery()
131133
{
134+
$query = "DELETE FROM {$this->delimitedTable}" . $this->tryDelimite($this->buildConditions());
132135
if ($this->limit !== NULL || $this->offset) {
133-
throw new Nette\NotSupportedException('LIMIT clause is not supported in DELETE query.');
136+
$this->driver->applyLimit($query, $this->limit, $this->offset);
134137
}
135-
return "DELETE FROM {$this->delimitedTable}" . $this->tryDelimite($this->buildConditions());
138+
139+
return $query;
136140
}
137141

138142

0 commit comments

Comments
 (0)