From c7f2debd38e35b0f049df9cc33ff8fb4eede40db Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 15 Aug 2012 18:21:28 +0200 Subject: Fix and finish the extra parameters storage system for MySQL --- OpenSim/Data/MySQL/MySQLSimulationData.cs | 58 ++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) (limited to 'OpenSim/Data') diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index be985ab..3fc04ee 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -1969,15 +1969,71 @@ namespace OpenSim.Data.MySQL public void SaveExtra(UUID regionID, string name, string val) { + lock (m_dbLock) + { + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.CommandText = "replace into regionextra values (?RegionID, ?Name, ?value)"; + cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); + cmd.Parameters.AddWithValue("?Name", name); + cmd.Parameters.AddWithValue("?value", val); + + cmd.ExecuteNonQuery(); + } + } + } } public void RemoveExtra(UUID regionID, string name) { + lock (m_dbLock) + { + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.CommandText = "delete from regionextra where RegionID=?RegionID and Name=?Name"; + cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); + cmd.Parameters.AddWithValue("?Name", name); + + cmd.ExecuteNonQuery(); + } + } + } } public Dictionary GetExtra(UUID regionID) { - return null; + Dictionary ret = new Dictionary(); + + lock (m_dbLock) + { + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + + using (MySqlCommand cmd = dbcon.CreateCommand()) + { + cmd.CommandText = "select * from regionextra where RegionID=?RegionID"; + cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); + using (IDataReader r = cmd.ExecuteReader()) + { + while (r.Read()) + { + ret[r["Name"].ToString()] = r["value"].ToString(); + } + } + } + } + } + + return ret; } } } -- cgit v1.1