diff options
Diffstat (limited to 'OpenSim/Data/MySQL/MySQLFriendsData.cs')
-rw-r--r-- | OpenSim/Data/MySQL/MySQLFriendsData.cs | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/OpenSim/Data/MySQL/MySQLFriendsData.cs b/OpenSim/Data/MySQL/MySQLFriendsData.cs index 130ba5e..3cd6b8f 100644 --- a/OpenSim/Data/MySQL/MySQLFriendsData.cs +++ b/OpenSim/Data/MySQL/MySQLFriendsData.cs | |||
@@ -49,34 +49,38 @@ namespace OpenSim.Data.MySQL | |||
49 | 49 | ||
50 | public bool Delete(string principalID, string friend) | 50 | public bool Delete(string principalID, string friend) |
51 | { | 51 | { |
52 | MySqlCommand cmd = new MySqlCommand(); | 52 | using (MySqlCommand cmd = new MySqlCommand()) |
53 | { | ||
54 | cmd.CommandText = String.Format("delete from {0} where PrincipalID = ?PrincipalID and Friend = ?Friend", m_Realm); | ||
55 | cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString()); | ||
56 | cmd.Parameters.AddWithValue("?Friend", friend); | ||
53 | 57 | ||
54 | cmd.CommandText = String.Format("delete from {0} where PrincipalID = ?PrincipalID and Friend = ?Friend", m_Realm); | 58 | ExecuteNonQuery(cmd); |
55 | cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString()); | 59 | } |
56 | cmd.Parameters.AddWithValue("?Friend", friend); | ||
57 | |||
58 | ExecuteNonQuery(cmd); | ||
59 | 60 | ||
60 | return true; | 61 | return true; |
61 | } | 62 | } |
62 | 63 | ||
63 | public FriendsData[] GetFriends(UUID principalID) | 64 | public FriendsData[] GetFriends(UUID principalID) |
64 | { | 65 | { |
65 | MySqlCommand cmd = new MySqlCommand(); | 66 | using (MySqlCommand cmd = new MySqlCommand()) |
66 | 67 | { | |
67 | cmd.CommandText = String.Format("select a.*,case when b.Flags is null then -1 else b.Flags end as TheirFlags from {0} as a left join {0} as b on a.PrincipalID = b.Friend and a.Friend = b.PrincipalID where a.PrincipalID = ?PrincipalID", m_Realm); | 68 | cmd.CommandText = String.Format("select a.*,case when b.Flags is null then -1 else b.Flags end as TheirFlags from {0} as a left join {0} as b on a.PrincipalID = b.Friend and a.Friend = b.PrincipalID where a.PrincipalID = ?PrincipalID", m_Realm); |
68 | cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString()); | 69 | cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString()); |
69 | 70 | ||
70 | return DoQuery(cmd); | 71 | return DoQuery(cmd); |
72 | } | ||
71 | } | 73 | } |
72 | 74 | ||
73 | public FriendsData[] GetFriends(string principalID) | 75 | public FriendsData[] GetFriends(string principalID) |
74 | { | 76 | { |
75 | MySqlCommand cmd = new MySqlCommand(); | 77 | using (MySqlCommand cmd = new MySqlCommand()) |
78 | { | ||
79 | cmd.CommandText = String.Format("select a.*,case when b.Flags is null then -1 else b.Flags end as TheirFlags from {0} as a left join {0} as b on a.PrincipalID = b.Friend and a.Friend = b.PrincipalID where a.PrincipalID LIKE ?PrincipalID", m_Realm); | ||
80 | cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString() + '%'); | ||
76 | 81 | ||
77 | cmd.CommandText = String.Format("select a.*,case when b.Flags is null then -1 else b.Flags end as TheirFlags from {0} as a left join {0} as b on a.PrincipalID = b.Friend and a.Friend = b.PrincipalID where a.PrincipalID LIKE ?PrincipalID", m_Realm); | 82 | return DoQuery(cmd); |
78 | cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString() + '%'); | 83 | } |
79 | return DoQuery(cmd); | ||
80 | } | 84 | } |
81 | } | 85 | } |
82 | } | 86 | } \ No newline at end of file |