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.cs60
1 files changed, 60 insertions, 0 deletions
diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs
index 995c6a5..35fa89f 100644
--- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs
+++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs
@@ -301,5 +301,65 @@ namespace OpenSim.Data.MySQL
301 return ExecuteNonQuery(cmd) > 0; 301 return ExecuteNonQuery(cmd) > 0;
302 } 302 }
303 } 303 }
304
305 public long GetCount(string field, string key)
306 {
307 return GetCount(new string[] { field }, new string[] { key });
308 }
309
310 public long GetCount(string[] fields, string[] keys)
311 {
312 if (fields.Length != keys.Length)
313 return 0;
314
315 List<string> terms = new List<string>();
316
317 using (MySqlCommand cmd = new MySqlCommand())
318 {
319 for (int i = 0; i < fields.Length; i++)
320 {
321 cmd.Parameters.AddWithValue(fields[i], keys[i]);
322 terms.Add("`" + fields[i] + "` = ?" + fields[i]);
323 }
324
325 string where = String.Join(" and ", terms.ToArray());
326
327 string query = String.Format("select count(*) from {0} where {1}",
328 m_Realm, where);
329
330 cmd.CommandText = query;
331
332 Object result = DoQueryScalar(cmd);
333
334 return Convert.ToInt64(result);
335 }
336 }
337
338 public long GetCount(string where)
339 {
340 using (MySqlCommand cmd = new MySqlCommand())
341 {
342 string query = String.Format("select count(*) from {0} where {1}",
343 m_Realm, where);
344
345 cmd.CommandText = query;
346
347 object result = DoQueryScalar(cmd);
348
349 return Convert.ToInt64(result);
350 }
351 }
352
353 public object DoQueryScalar(MySqlCommand cmd)
354 {
355 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
356 {
357 dbcon.Open();
358 cmd.Connection = dbcon;
359
360 return cmd.ExecuteScalar();
361 }
362 }
363
304 } 364 }
305} \ No newline at end of file 365} \ No newline at end of file