DBServer::Remove PHP Method

Remove() public method

Removes server from database
public Remove ( ) : void
return void
    public function Remove()
    {
        try {
            // 1. Clean up cloud objects
            if ($this->platform == SERVER_PLATFORMS::AZURE) {
                AzureHelper::cleanupServerObjects($this);
            }
            // 2. Cleanup scalr db
            $this->Db->BeginTrans();
            // We need to perpetuate server_properties records for removed servers
            $this->Db->Execute("DELETE FROM servers WHERE server_id=?", array($this->serverId));
            $this->Db->Execute("DELETE FROM messages WHERE server_id=?", array($this->serverId));
            $importantProperties = \SERVER_PROPERTIES::getImportantList();
            $properties = array_diff(array_keys($this->GetAllProperties()), $importantProperties);
            if (!empty($properties)) {
                $and = " AND (";
                foreach ($properties as $name) {
                    $and .= "name=" . $this->Db->qstr($name) . " OR ";
                }
                $and = substr($and, 0, -3) . ")";
                $this->Db->Execute("DELETE FROM server_properties WHERE server_id=?" . $and, [$this->serverId]);
            }
            $this->Db->CommitTrans();
        } catch (Exception $e) {
            $this->Db->RollbackTrans();
            throw $e;
        }
    }