Implement generic delete method

0.6.8-post-fixes
Melanie 2009-11-18 08:53:07 +00:00
parent 06ecdf1967
commit 23438e66e7
2 changed files with 16 additions and 2 deletions

View File

@ -48,7 +48,8 @@ namespace OpenSim.Data
PresenceData Get(UUID principalID); PresenceData Get(UUID principalID);
bool SetDataItem(UUID principalID, string item, string value); bool SetUserDataItem(UUID principalID, string item, string value);
bool SetRegionDataItem(UUID principalID, string item, string value);
bool Delete(UUID regionID); bool Delete(UUID regionID);
} }

View File

@ -112,7 +112,7 @@ namespace OpenSim.Data.MySQL
for (int i = 0 ; i < fields.Length ; i++) for (int i = 0 ; i < fields.Length ; i++)
{ {
cmd.Parameters.AddWithValue(fields[i], keys[i]); cmd.Parameters.AddWithValue(fields[i], keys[i]);
terms.Add(fields[i] + " = ?" + fields[i]); terms.Add("`" + fields[i] + "` = ?" + fields[i]);
} }
string where = String.Join(" and ", terms.ToArray()); string where = String.Join(" and ", terms.ToArray());
@ -198,5 +198,18 @@ namespace OpenSim.Data.MySQL
return false; return false;
} }
public bool Delete(string field, string val)
{
MySqlCommand cmd = new MySqlCommand();
cmd.CommandText = String.Format("delete from {0} where `{1}` = ?{1}", m_Realm, field);
cmd.Parameters.AddWithValue(field, val);
if (ExecuteNonQuery(cmd) > 0)
return true;
return false;
}
} }
} }