aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/PGSQL/PGSQLGenericTableHandler.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Data/PGSQL/PGSQLGenericTableHandler.cs')
-rw-r--r--OpenSim/Data/PGSQL/PGSQLGenericTableHandler.cs49
1 files changed, 48 insertions, 1 deletions
diff --git a/OpenSim/Data/PGSQL/PGSQLGenericTableHandler.cs b/OpenSim/Data/PGSQL/PGSQLGenericTableHandler.cs
index 5b24720..a89183b 100644
--- a/OpenSim/Data/PGSQL/PGSQLGenericTableHandler.cs
+++ b/OpenSim/Data/PGSQL/PGSQLGenericTableHandler.cs
@@ -180,7 +180,54 @@ namespace OpenSim.Data.PGSQL
180 180
181 public virtual T[] Get(string field, string key) 181 public virtual T[] Get(string field, string key)
182 { 182 {
183 return Get(new string[] { field }, new string[] { key }); 183 using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
184 using (NpgsqlCommand cmd = new NpgsqlCommand())
185 {
186 if ( m_FieldTypes.ContainsKey(field) )
187 cmd.Parameters.Add(m_database.CreateParameter(field, key, m_FieldTypes[field]));
188 else
189 cmd.Parameters.Add(m_database.CreateParameter(field, key));
190
191 string query = String.Format("SELECT * FROM {0} WHERE \"{1}\" = :{1}", m_Realm, field, field);
192
193 cmd.Connection = conn;
194 cmd.CommandText = query;
195 conn.Open();
196 return DoQuery(cmd);
197 }
198 }
199
200 public virtual T[] Get(string field, string[] keys)
201 {
202
203 int flen = keys.Length;
204 if(flen == 0)
205 return new T[0];
206
207 int flast = flen - 1;
208 StringBuilder sb = new StringBuilder(1024);
209 sb.AppendFormat("select * from {0} where {1} IN ('", m_Realm, field);
210
211 using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
212 using (NpgsqlCommand cmd = new NpgsqlCommand())
213 {
214
215 for (int i = 0 ; i < flen ; i++)
216 {
217 sb.Append(keys[i]);
218 if(i < flast)
219 sb.Append("','");
220 else
221 sb.Append("')");
222 }
223
224 string query = sb.ToString();
225
226 cmd.Connection = conn;
227 cmd.CommandText = query;
228 conn.Open();
229 return DoQuery(cmd);
230 }
184 } 231 }
185 232
186 public virtual T[] Get(string[] fields, string[] keys) 233 public virtual T[] Get(string[] fields, string[] keys)