From 06ecdf1967848e3f0c6b6f98aba61c7ad099f65d Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 18 Nov 2009 08:21:28 +0000 Subject: Tweak presence handling and whip up a database connector and handler for testign the new generic table handling --- OpenSim/Data/IPresenceData.cs | 4 ++-- OpenSim/Data/MySQL/MySQLGenericTableHandler.cs | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'OpenSim/Data') diff --git a/OpenSim/Data/IPresenceData.cs b/OpenSim/Data/IPresenceData.cs index 891b590..020ba5d 100644 --- a/OpenSim/Data/IPresenceData.cs +++ b/OpenSim/Data/IPresenceData.cs @@ -32,11 +32,11 @@ using OpenSim.Framework; namespace OpenSim.Data { - public class PresenceData + public struct PresenceData { public UUID UUID; public UUID currentRegion; - public Dictionary Data; + public Dictionary Data; } /// diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs index 4eb4a24..1521dc7 100644 --- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs +++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs @@ -190,11 +190,13 @@ namespace OpenSim.Data.MySQL return DoQuery(cmd); } - public void Store(T row) + public bool Store(T row) { MySqlCommand cmd = new MySqlCommand(); string query = ""; + + return false; } } } -- cgit v1.1 From 23438e66e7ee3cd71652cdf6fd6a801544179ec0 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 18 Nov 2009 08:53:07 +0000 Subject: Implement generic delete method --- OpenSim/Data/IPresenceData.cs | 3 ++- OpenSim/Data/MySQL/MySQLGenericTableHandler.cs | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data') diff --git a/OpenSim/Data/IPresenceData.cs b/OpenSim/Data/IPresenceData.cs index 020ba5d..e5a8ebd 100644 --- a/OpenSim/Data/IPresenceData.cs +++ b/OpenSim/Data/IPresenceData.cs @@ -48,7 +48,8 @@ namespace OpenSim.Data 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); } diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs index 1521dc7..4e27e26 100644 --- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs +++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs @@ -112,7 +112,7 @@ namespace OpenSim.Data.MySQL for (int i = 0 ; i < fields.Length ; 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()); @@ -198,5 +198,18 @@ namespace OpenSim.Data.MySQL 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; + } } } -- cgit v1.1