aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/MSSQL
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Data/MSSQL')
-rw-r--r--OpenSim/Data/MSSQL/MSSQLGenericTableHandler.cs35
-rw-r--r--OpenSim/Data/MSSQL/MSSQLXInventoryData.cs10
2 files changed, 33 insertions, 12 deletions
diff --git a/OpenSim/Data/MSSQL/MSSQLGenericTableHandler.cs b/OpenSim/Data/MSSQL/MSSQLGenericTableHandler.cs
index 19e8fa6..6e695ce 100644
--- a/OpenSim/Data/MSSQL/MSSQLGenericTableHandler.cs
+++ b/OpenSim/Data/MSSQL/MSSQLGenericTableHandler.cs
@@ -335,24 +335,35 @@ namespace OpenSim.Data.MSSQL
335 } 335 }
336 } 336 }
337 337
338 public virtual bool Delete(string field, string val) 338 public virtual bool Delete(string field, string key)
339 { 339 {
340 return Delete(new string[] { field }, new string[] { key });
341 }
342
343 public virtual bool Delete(string[] fields, string[] keys)
344 {
345 if (fields.Length != keys.Length)
346 return false;
347
348 List<string> terms = new List<string>();
349
340 using (SqlConnection conn = new SqlConnection(m_ConnectionString)) 350 using (SqlConnection conn = new SqlConnection(m_ConnectionString))
341 using (SqlCommand cmd = new SqlCommand()) 351 using (SqlCommand cmd = new SqlCommand())
342 { 352 {
343 string deleteCommand = String.Format("DELETE FROM {0} WHERE [{1}] = @{1}", m_Realm, field); 353 for (int i = 0; i < fields.Length; i++)
344 cmd.CommandText = deleteCommand;
345
346 cmd.Parameters.Add(m_database.CreateParameter(field, val));
347 cmd.Connection = conn;
348 conn.Open();
349
350 if (cmd.ExecuteNonQuery() > 0)
351 { 354 {
352 //m_log.Warn("[MSSQLGenericTable]: " + deleteCommand); 355 cmd.Parameters.Add(m_database.CreateParameter(fields[i], keys[i]));
353 return true; 356 terms.Add("[" + fields[i] + "] = @" + fields[i]);
354 } 357 }
355 return false; 358
359 string where = String.Join(" AND ", terms.ToArray());
360
361 string query = String.Format("DELETE * FROM {0} WHERE {1}", m_Realm, where);
362
363 cmd.Connection = conn;
364 cmd.CommandText = query;
365 conn.Open();
366 return cmd.ExecuteNonQuery() > 0;
356 } 367 }
357 } 368 }
358 } 369 }
diff --git a/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs b/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs
index 739eb55..dc35a2e 100644
--- a/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs
+++ b/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs
@@ -79,11 +79,21 @@ namespace OpenSim.Data.MSSQL
79 return m_Folders.Delete(field, val); 79 return m_Folders.Delete(field, val);
80 } 80 }
81 81
82 public bool DeleteFolders(string[] fields, string[] vals)
83 {
84 return m_Folders.Delete(fields, vals);
85 }
86
82 public bool DeleteItems(string field, string val) 87 public bool DeleteItems(string field, string val)
83 { 88 {
84 return m_Items.Delete(field, val); 89 return m_Items.Delete(field, val);
85 } 90 }
86 91
92 public bool DeleteItems(string[] fields, string[] vals)
93 {
94 return m_Items.Delete(fields, vals);
95 }
96
87 public bool MoveItem(string id, string newParent) 97 public bool MoveItem(string id, string newParent)
88 { 98 {
89 return m_Items.MoveItem(id, newParent); 99 return m_Items.MoveItem(id, newParent);