aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Data/MySQL/MySQLGenericTableHandler.cs')
-rw-r--r--OpenSim/Data/MySQL/MySQLGenericTableHandler.cs28
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;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Data; 30using System.Data;
31using System.Reflection; 31using System.Reflection;
32using log4net; 32using System.Text;
33using MySql.Data.MySqlClient; 33using MySql.Data.MySqlClient;
34using OpenMetaverse; 34using OpenMetaverse;
35using OpenSim.Framework;
36using OpenSim.Region.Framework.Interfaces;
37 35
38namespace OpenSim.Data.MySQL 36namespace 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 {