function DeleteDevice() { global $dbh; // Can't delete something that doesn't exist if (!$this->GetDevice()) { return false; } // First, see if this is a chassis that has children, if so, delete all of the children first if ($this->ChassisSlots > 0) { $childList = $this->GetDeviceChildren(); foreach ($childList as $tmpDev) { $tmpDev->DeleteDevice(); } } // If this is a CDU then remove it from the other table if ($this->DeviceType == "CDU") { $pdu = new PowerDistribution(); $pdu->PDUID = $this->DeviceID; $pdu->DeletePDU(); } // Delete all network connections first DevicePorts::removePorts($this->DeviceID); // Delete power connections next PowerPorts::removePorts($this->DeviceID); // Remove custom values $this->DeleteCustomValues(); // Now delete the device itself $sql = "DELETE FROM fac_Device WHERE DeviceID={$this->DeviceID};"; if (!$dbh->exec($sql)) { $info = $dbh->errorInfo(); error_log("PDO Error: {$info[2]} SQL={$sql}"); return false; } class_exists('LogActions') ? LogActions::LogThis($this) : ''; return; }