diff --git a/backend/src/operations/Domains.php b/backend/src/operations/Domains.php index e87a7cb..a5c089f 100644 --- a/backend/src/operations/Domains.php +++ b/backend/src/operations/Domains.php @@ -191,7 +191,10 @@ class Domains throw new \Exceptions\NotFoundException(); } - $query = $this->db->prepare('DELETE FROM domains WHERE id=:id'); + $query = $this->db->prepare(' + DELETE E FROM remote E + LEFT OUTER JOIN records R ON R.id=E.record + WHERE R.domain_id=:id'); $query->bindValue(':id', $id, \PDO::PARAM_INT); $query->execute(); @@ -199,6 +202,10 @@ class Domains $query->bindValue(':id', $id, \PDO::PARAM_INT); $query->execute(); + $query = $this->db->prepare('DELETE FROM domains WHERE id=:id'); + $query->bindValue(':id', $id, \PDO::PARAM_INT); + $query->execute(); + $this->db->commit(); } diff --git a/backend/src/operations/Records.php b/backend/src/operations/Records.php index 484a975..518de71 100644 --- a/backend/src/operations/Records.php +++ b/backend/src/operations/Records.php @@ -215,6 +215,10 @@ class Records throw new \Exceptions\NotFoundException(); } + $query = $this->db->prepare('DELETE FROM remote WHERE record=:id'); + $query->bindValue(':id', $id, \PDO::PARAM_INT); + $query->execute(); + $query = $this->db->prepare('DELETE FROM records WHERE id=:id'); $query->bindValue(':id', $id, \PDO::PARAM_INT); $query->execute();