function Save()
{
$row = $this->Unbind();
unset($row['server_id']);
unset($row['id']);
// Prepare SQL statement
$set = [];
$bind = [];
foreach ($row as $field => $value) {
$set[] = "`{$field}` = ?";
$bind[] = $value;
}
$set = join(', ', $set);
try {
if ($this->dbId) {
// Perform Update
$bind[] = $this->dbId;
$this->Db->Execute("UPDATE servers SET {$set} WHERE id = ?", $bind);
} else {
// Perform Insert
$this->Db->Execute("INSERT INTO servers SET {$set}", $bind);
$this->dbId = $this->Db->Insert_ID();
}
} catch (Exception $e) {
throw new Exception("Cannot save server. Error: " . $e->getMessage(), $e->getCode());
}
}