From c9a24ece546fb20977d27abef736cd5e45d976e2 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 4 Sep 2009 03:13:32 +0100 Subject: More work on new authentication service --- OpenSim/Data/MySQL/MySQLAuthenticationData.cs | 35 ++++++++++++++++++--------- 1 file changed, 23 insertions(+), 12 deletions(-) (limited to 'OpenSim/Data/MySQL/MySQLAuthenticationData.cs') diff --git a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs index 625d3b1..19575ec 100644 --- a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs +++ b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs @@ -38,7 +38,7 @@ namespace OpenSim.Data.MySQL public class MySqlAuthenticationData : MySqlFramework, IAuthenticationData { private string m_Realm; - private DataTable m_SchemaTable = null; + private List m_ColumnNames = null; public MySqlAuthenticationData(string connectionString, string realm) : base(connectionString) @@ -63,15 +63,21 @@ namespace OpenSim.Data.MySQL { ret.PrincipalID = principalID; - if (m_SchemaTable == null) - m_SchemaTable = result.GetSchemaTable(); + if (m_ColumnNames == null) + { + m_ColumnNames = new List(); + + DataTable schemaTable = result.GetSchemaTable(); + foreach (DataRow row in schemaTable.Rows) + m_ColumnNames.Add(row["ColumnName"].ToString()); + } - foreach (DataColumn c in m_SchemaTable.Columns) + foreach (string s in m_ColumnNames) { - if (c.ColumnName == "UUID") + if (s == "UUID") continue; - ret.Data[c.ColumnName] = result[c.ColumnName].ToString(); + ret.Data[s] = result[s].ToString(); } result.Close(); @@ -105,21 +111,23 @@ namespace OpenSim.Data.MySQL first = false; - cmd.Parameters.AddWithValue(field, data.Data[field]); + cmd.Parameters.AddWithValue("?"+field, data.Data[field]); } update += " where UUID = ?principalID"; cmd.CommandText = update; - cmd.Parameters.AddWithValue("UUID", data.PrincipalID.ToString()); + cmd.Parameters.AddWithValue("?principalID", data.PrincipalID.ToString()); if (ExecuteNonQuery(cmd) < 1) { string insert = "insert into `" + m_Realm + "` (`UUID`, `" + String.Join("`, `", fields) + - "`) values ( ?UUID, ?" + String.Join(", ?", fields) + ")"; + "`) values ( ?principalID, ?" + String.Join(", ?", fields) + ")"; - if (ExecuteNonQuery(cmd) < 0) + cmd.CommandText = insert; + + if (ExecuteNonQuery(cmd) < 1) { cmd.Dispose(); return false; @@ -137,8 +145,11 @@ namespace OpenSim.Data.MySQL "` set `" + item + "` = ?" + item + " where UUID = ?UUID"); - cmd.Parameters.AddWithValue(item, value); - cmd.Parameters.AddWithValue("UUID", principalID.ToString()); + cmd.Parameters.AddWithValue("?"+item, value); + cmd.Parameters.AddWithValue("?UUID", principalID.ToString()); + + if (ExecuteNonQuery(cmd) > 0) + return true; return false; } -- cgit v1.1