29 using System.Collections;
30 using System.Collections.Generic;
33 using OpenSim.Framework;
37 using System.Reflection;
39 namespace OpenSim.Data.PGSQL
43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
47 base(connectionString, realm,
"UserAccount")
282 string[] words = query.Split(
new char[] {
' ' });
284 for (
int i = 0; i < words.Length; i++)
286 if (words[i].Length < 3)
288 if (i != words.Length - 1)
289 Array.Copy(words, i + 1, words, i, words.Length - i - 1);
290 Array.Resize(ref words, words.Length - 1);
294 if (words.Length == 0)
297 if (words.Length > 2)
302 UUID.TryParse(scopeID.ToString(), out scope_id);
304 using (NpgsqlConnection conn =
new NpgsqlConnection(m_ConnectionString))
305 using (NpgsqlCommand cmd =
new NpgsqlCommand())
307 if (words.Length == 1)
309 sql = String.Format(
@"select * from {0} where (""ScopeID""=:ScopeID or ""ScopeID""=:UUIDZero) and (""FirstName"" ilike :search or ""LastName"" ilike :search)", m_Realm);
310 cmd.Parameters.Add(m_database.CreateParameter(
"scopeID", (UUID)scope_id));
311 cmd.Parameters.Add (m_database.CreateParameter(
"UUIDZero", (UUID)UUID.Zero));
312 cmd.Parameters.Add(m_database.CreateParameter(
"search",
"%" + words[0] +
"%"));
316 sql = String.Format(
@"select * from {0} where (""ScopeID""=:ScopeID or ""ScopeID""=:UUIDZero) and (""FirstName"" ilike :searchFirst or ""LastName"" ilike :searchLast)", m_Realm);
317 cmd.Parameters.Add(m_database.CreateParameter(
"searchFirst",
"%" + words[0] +
"%"));
318 cmd.Parameters.Add(m_database.CreateParameter(
"searchLast",
"%" + words[1] +
"%"));
319 cmd.Parameters.Add (m_database.CreateParameter(
"UUIDZero", (UUID)UUID.Zero));
320 cmd.Parameters.Add(m_database.CreateParameter(
"ScopeID", (UUID)scope_id));
322 cmd.Connection = conn;
323 cmd.CommandText = sql;
PGSQLUserAccountData(string connectionString, string realm)
UserAccountData[] GetUsersWhere(UUID scopeID, string where)
An interface for connecting to the user accounts datastore
UserAccountData[] GetUsers(UUID scopeID, string query)