mirror of
https://github.com/getnamingo/registry.git
synced 2025-08-06 01:25:00 +02:00
Further PostgreSQL compatibility
This commit is contained in:
parent
5dc5160f8e
commit
bc8f904c3a
4 changed files with 63 additions and 63 deletions
|
@ -15,9 +15,9 @@ try {
|
|||
|
||||
try {
|
||||
// Prepare and execute the SQL statement to select unused hosts
|
||||
$stmt = $dbh->prepare("SELECT `h`.`id`,`h`.`name` FROM `host` AS `h`
|
||||
LEFT JOIN `domain_host_map` AS `m` ON `h`.`id` = `m`.`host_id`
|
||||
WHERE `m`.`host_id` IS NULL AND `h`.`domain_id` IS NULL AND `h`.`crdate` < (NOW() - INTERVAL 1 MONTH)");
|
||||
$stmt = $dbh->prepare("SELECT h.id, h.name FROM host AS h
|
||||
LEFT JOIN domain_host_map AS m ON h.id = m.host_id
|
||||
WHERE m.host_id IS NULL AND h.domain_id IS NULL AND h.crdate < (NOW() - INTERVAL 1 MONTH)");
|
||||
$stmt->execute();
|
||||
|
||||
$ids = [];
|
||||
|
@ -28,16 +28,16 @@ try {
|
|||
// Delete associated records from various tables for hosts
|
||||
if (!empty($ids)) {
|
||||
$placeholders = implode(',', array_fill(0, count($ids), '?'));
|
||||
$dbh->prepare("DELETE FROM `host_status` WHERE `host_id` IN ($placeholders)")->execute($ids);
|
||||
$dbh->prepare("DELETE FROM `host_addr` WHERE `host_id` IN ($placeholders)")->execute($ids);
|
||||
$dbh->prepare("DELETE FROM `host` WHERE `id` IN ($placeholders)")->execute($ids);
|
||||
$dbh->prepare("DELETE FROM host_status WHERE host_id IN ($placeholders)")->execute($ids);
|
||||
$dbh->prepare("DELETE FROM host_addr WHERE host_id IN ($placeholders)")->execute($ids);
|
||||
$dbh->prepare("DELETE FROM host WHERE id IN ($placeholders)")->execute($ids);
|
||||
}
|
||||
|
||||
// Prepare and execute the SQL statement to select unused contacts
|
||||
$stmt = $dbh->prepare("SELECT `c`.`id`,`c`.`identifier` FROM `contact` AS `c`
|
||||
LEFT JOIN `domain_contact_map` AS `m` ON `c`.`id` = `m`.`contact_id`
|
||||
LEFT JOIN `domain` AS `d` ON `c`.`id` = `d`.`registrant`
|
||||
WHERE `m`.`contact_id` IS NULL AND `d`.`registrant` IS NULL AND `c`.`crdate` < (NOW() - INTERVAL 1 MONTH)");
|
||||
$stmt = $dbh->prepare("SELECT c.id, c.identifier FROM contact AS c
|
||||
LEFT JOIN domain_contact_map AS m ON c.id = m.contact_id
|
||||
LEFT JOIN domain AS d ON c.id = d.registrant
|
||||
WHERE m.contact_id IS NULL AND d.registrant IS NULL AND c.crdate < (NOW() - INTERVAL 1 MONTH)");
|
||||
$stmt->execute();
|
||||
|
||||
$contact_ids = [];
|
||||
|
@ -48,10 +48,10 @@ try {
|
|||
// Delete associated records from various tables for contacts
|
||||
if (!empty($contact_ids)) {
|
||||
$placeholders = implode(',', array_fill(0, count($contact_ids), '?'));
|
||||
$dbh->prepare("DELETE FROM `contact_status` WHERE `contact_id` IN ($placeholders)")->execute($contact_ids);
|
||||
$dbh->prepare("DELETE FROM `contact_postalInfo` WHERE `contact_id` IN ($placeholders)")->execute($contact_ids);
|
||||
$dbh->prepare("DELETE FROM `contact_authInfo` WHERE `contact_id` IN ($placeholders)")->execute($contact_ids);
|
||||
$dbh->prepare("DELETE FROM `contact` WHERE `id` IN ($placeholders)")->execute($contact_ids);
|
||||
$dbh->prepare("DELETE FROM contact_status WHERE contact_id IN ($placeholders)")->execute($contact_ids);
|
||||
$dbh->prepare("DELETE FROM contact_postalInfo WHERE contact_id IN ($placeholders)")->execute($contact_ids);
|
||||
$dbh->prepare("DELETE FROM contact_authInfo WHERE contact_id IN ($placeholders)")->execute($contact_ids);
|
||||
$dbh->prepare("DELETE FROM contact WHERE id IN ($placeholders)")->execute($contact_ids);
|
||||
}
|
||||
|
||||
} catch (PDOException $e) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue