aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/MySQL/MySQLUserAccountData.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Data/MySQL/MySQLUserAccountData.cs48
1 files changed, 25 insertions, 23 deletions
diff --git a/OpenSim/Data/MySQL/MySQLUserAccountData.cs b/OpenSim/Data/MySQL/MySQLUserAccountData.cs
index a18ac66..4ff3175 100644
--- a/OpenSim/Data/MySQL/MySQLUserAccountData.cs
+++ b/OpenSim/Data/MySQL/MySQLUserAccountData.cs
@@ -66,38 +66,40 @@ namespace OpenSim.Data.MySQL
66 if (words.Length > 2) 66 if (words.Length > 2)
67 return new UserAccountData[0]; 67 return new UserAccountData[0];
68 68
69 MySqlCommand cmd = new MySqlCommand(); 69 using (MySqlCommand cmd = new MySqlCommand())
70
71 if (words.Length == 1)
72 {
73 cmd.CommandText = String.Format("select * from {0} where (ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like ?search or LastName like ?search) and active=1", m_Realm);
74 cmd.Parameters.AddWithValue("?search", words[0] + "%");
75 cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString());
76 }
77 else
78 { 70 {
79 cmd.CommandText = String.Format("select * from {0} where (ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like ?searchFirst and LastName like ?searchLast) and active=1", m_Realm); 71 if (words.Length == 1)
80 cmd.Parameters.AddWithValue("?searchFirst", words[0] + "%"); 72 {
81 cmd.Parameters.AddWithValue("?searchLast", words[1] + "%"); 73 cmd.CommandText = String.Format("select * from {0} where (ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like ?search or LastName like ?search) and active=1", m_Realm);
82 cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString()); 74 cmd.Parameters.AddWithValue("?search", words[0] + "%");
83 } 75 cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString());
76 }
77 else
78 {
79 cmd.CommandText = String.Format("select * from {0} where (ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like ?searchFirst and LastName like ?searchLast) and active=1", m_Realm);
80 cmd.Parameters.AddWithValue("?searchFirst", words[0] + "%");
81 cmd.Parameters.AddWithValue("?searchLast", words[1] + "%");
82 cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString());
83 }
84 84
85 return DoQuery(cmd); 85 return DoQuery(cmd);
86 }
86 } 87 }
87 88
88 public UserAccountData[] GetUsersWhere(UUID scopeID, string where) 89 public UserAccountData[] GetUsersWhere(UUID scopeID, string where)
89 { 90 {
90 MySqlCommand cmd = new MySqlCommand(); 91 using (MySqlCommand cmd = new MySqlCommand())
91
92 if (scopeID != UUID.Zero)
93 { 92 {
94 where = "(ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (" + where + ")"; 93 if (scopeID != UUID.Zero)
95 cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString()); 94 {
96 } 95 where = "(ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (" + where + ")";
96 cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString());
97 }
97 98
98 cmd.CommandText = String.Format("select * from {0} where " + where, m_Realm); 99 cmd.CommandText = String.Format("select * from {0} where " + where, m_Realm);
99 100
100 return DoQuery(cmd); 101 return DoQuery(cmd);
102 }
101 } 103 }
102 } 104 }
103} 105}