refactor: Replace custom queries with dbDeleteOrphans(). (#7862)

* Replace custom queries with dbDeleteOrphans().
Generalize dbDeleteOrphans() a bit more.  Allow for multiple tables and custom key pairs.

* fix whitespace
This commit is contained in:
Tony Murray
2017-12-06 16:44:23 -06:00
committed by Neil Lathwood
parent daa0773f48
commit 8ab0b2bffd
4 changed files with 34 additions and 17 deletions

View File

@@ -117,10 +117,7 @@ foreach ($vrfs_lite_cisco as $vrf) {
}
// remove entries that no longer have an owner
dbQuery('DELETE `ipv4_mac` FROM `ipv4_mac`
LEFT JOIN `ports` ON `ipv4_mac`.`port_id` = `ports`.`port_id`
LEFT JOIN `devices` ON `ipv4_mac`.`device_id` = `devices`.`device_id`
WHERE `ports`.`port_id` IS NULL OR `devices`.`device_id` IS NULL');
dbDeleteOrphans('ipv4_mac', array('ports.port_id', 'devices.device_id'));
echo PHP_EOL;
unset(