From dfd800e26341a6e4e91286a19820445253aa4abd Mon Sep 17 00:00:00 2001 From: Victor Westerlund Date: Tue, 29 Jul 2025 09:40:15 +0200 Subject: [PATCH] fix: set WHERE for DELET statement only if conditions are provided --- src/MySQL.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/MySQL.php b/src/MySQL.php index 1dff427..e7ddb7c 100644 --- a/src/MySQL.php +++ b/src/MySQL.php @@ -268,9 +268,14 @@ $this->throw_if_no_table(); // 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}`{$this->filter_sql}"; return $this->execute_query($sql, self::to_list_array($this->filter_values)); }