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