diff options
Diffstat (limited to 'OpenSim/Data/MySQL/MySQLGenericTableHandler.cs')
-rw-r--r-- | OpenSim/Data/MySQL/MySQLGenericTableHandler.cs | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs index 9bd3c0c..1564140 100644 --- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs +++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs | |||
@@ -29,11 +29,9 @@ using System; | |||
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Data; | 30 | using System.Data; |
31 | using System.Reflection; | 31 | using System.Reflection; |
32 | using log4net; | 32 | using System.Text; |
33 | using MySql.Data.MySqlClient; | 33 | using MySql.Data.MySqlClient; |
34 | using OpenMetaverse; | 34 | using OpenMetaverse; |
35 | using OpenSim.Framework; | ||
36 | using OpenSim.Region.Framework.Interfaces; | ||
37 | 35 | ||
38 | namespace OpenSim.Data.MySQL | 36 | namespace OpenSim.Data.MySQL |
39 | { | 37 | { |
@@ -129,25 +127,27 @@ namespace OpenSim.Data.MySQL | |||
129 | 127 | ||
130 | public virtual T[] Get(string[] fields, string[] keys, string options) | 128 | public virtual T[] Get(string[] fields, string[] keys, string options) |
131 | { | 129 | { |
132 | if (fields.Length != keys.Length) | 130 | int flen = fields.Length; |
131 | if (flen == 0 || flen != keys.Length) | ||
133 | return new T[0]; | 132 | return new T[0]; |
134 | 133 | ||
135 | List<string> terms = new List<string>(); | 134 | int flast = flen - 1; |
135 | StringBuilder sb = new StringBuilder(1024); | ||
136 | sb.AppendFormat("select * from {0} where ", m_Realm); | ||
136 | 137 | ||
137 | using (MySqlCommand cmd = new MySqlCommand()) | 138 | using (MySqlCommand cmd = new MySqlCommand()) |
138 | { | 139 | { |
139 | for (int i = 0 ; i < fields.Length ; i++) | 140 | for (int i = 0 ; i < flen ; i++) |
140 | { | 141 | { |
141 | cmd.Parameters.AddWithValue(fields[i], keys[i]); | 142 | cmd.Parameters.AddWithValue(fields[i], keys[i]); |
142 | terms.Add("`" + fields[i] + "` = ?" + fields[i]); | 143 | if(i< flast) |
144 | sb.AppendFormat("`{0}` = ?{0} and ", fields[i]); | ||
145 | else | ||
146 | sb.AppendFormat("`{0}` = ?{0} ", fields[i]); | ||
143 | } | 147 | } |
144 | 148 | ||
145 | string where = String.Join(" and ", terms.ToArray()); | 149 | sb.Append(options); |
146 | 150 | cmd.CommandText = sb.ToString(); | |
147 | string query = String.Format("select * from {0} where {1} {2}", | ||
148 | m_Realm, where, options); | ||
149 | |||
150 | cmd.CommandText = query; | ||
151 | 151 | ||
152 | return DoQuery(cmd); | 152 | return DoQuery(cmd); |
153 | } | 153 | } |
@@ -204,7 +204,7 @@ namespace OpenSim.Data.MySQL | |||
204 | if (m_Fields[name].FieldType == typeof(bool)) | 204 | if (m_Fields[name].FieldType == typeof(bool)) |
205 | { | 205 | { |
206 | int v = Convert.ToInt32(reader[name]); | 206 | int v = Convert.ToInt32(reader[name]); |
207 | m_Fields[name].SetValue(row, v != 0 ? true : false); | 207 | m_Fields[name].SetValue(row, v != 0); |
208 | } | 208 | } |
209 | else if (m_Fields[name].FieldType == typeof(UUID)) | 209 | else if (m_Fields[name].FieldType == typeof(UUID)) |
210 | { | 210 | { |