aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs
diff options
context:
space:
mode:
authorDiva Canto2013-02-18 12:08:05 -0800
committerDiva Canto2013-02-18 12:08:05 -0800
commit8b1b8a3921595088e85f4e11bc2b1d335aed83aa (patch)
tree5a52e5500ac9fcbc085b8a62b854afa50c1c38ff /OpenSim/Data/MySQL/MySQLGenericTableHandler.cs
parentBulletSim: experimental lock axis code using constraints. Not enabled (diff)
downloadopensim-SC_OLD-8b1b8a3921595088e85f4e11bc2b1d335aed83aa.zip
opensim-SC_OLD-8b1b8a3921595088e85f4e11bc2b1d335aed83aa.tar.gz
opensim-SC_OLD-8b1b8a3921595088e85f4e11bc2b1d335aed83aa.tar.bz2
opensim-SC_OLD-8b1b8a3921595088e85f4e11bc2b1d335aed83aa.tar.xz
I need these for OfflineIM and Groups.
Diffstat (limited to '')
-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