Fixed bug where remotes without records or domains were left in the db

This commit is contained in:
Lukas Metzger 2018-04-02 13:45:24 +02:00
parent 15ff44a86e
commit ee1b081447
2 changed files with 12 additions and 1 deletions

View file

@ -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();
}

View file

@ -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();