mirror of
https://codeberg.org/vlw/php-mysql.git
synced 2025-09-14 08:43:40 +02:00
Compare commits
3 commits
Author | SHA1 | Date | |
---|---|---|---|
73297feb82 | |||
0e367f797f | |||
ddcd8a2961 |
1 changed files with 10 additions and 14 deletions
|
@ -35,7 +35,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private function throw_if_no_table() {
|
private function throw_if_no_table() {
|
||||||
if (!$this->table) {
|
if (!isset($this->table)) {
|
||||||
throw new Exception("No table name defined");
|
throw new Exception("No table name defined");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -163,17 +163,8 @@
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set LIMIT without range directly as integer
|
// Coerce offset to zero if no offset is defined
|
||||||
if (is_int($limit)) {
|
$offset = $offset ?? 0;
|
||||||
$this->limit = $limit;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
// No offset defined, set limit property directly as string
|
|
||||||
if (is_null($offset)) {
|
|
||||||
$this->limit = (string) $limit;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set limit and offset as SQL CSV
|
// Set limit and offset as SQL CSV
|
||||||
$this->limit = "{$offset},{$limit}";
|
$this->limit = "{$offset},{$limit}";
|
||||||
|
@ -277,9 +268,14 @@
|
||||||
$this->throw_if_no_table();
|
$this->throw_if_no_table();
|
||||||
|
|
||||||
// Set DELETE WHERE conditions from arguments
|
// Set DELETE WHERE conditions from arguments
|
||||||
$this->where(...$conditions);
|
if ($conditions) {
|
||||||
|
$this->where(...$conditions);
|
||||||
|
}
|
||||||
|
|
||||||
$sql = "DELETE FROM `{$this->table}` WHERE {$this->filter_sql}";
|
// Get array of SQL WHERE string and filter values
|
||||||
|
$filter_sql = !is_null($this->filter_sql) ? " WHERE {$this->filter_sql}" : "";
|
||||||
|
|
||||||
|
$sql = "DELETE FROM `{$this->table}`{$filter_sql}";
|
||||||
return $this->execute_query($sql, self::to_list_array($this->filter_values));
|
return $this->execute_query($sql, self::to_list_array($this->filter_values));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue