parametrize like clauses for avatar picker
parent
82d43db1cc
commit
333826903c
|
@ -52,6 +52,9 @@ namespace OpenSim.Framework.Data.SQLite
|
||||||
private const string userSelect = "select * from users";
|
private const string userSelect = "select * from users";
|
||||||
private const string userFriendsSelect = "select a.ownerID as ownerID,a.friendID as friendID,a.friendPerms as friendPerms,b.friendPerms as ownerperms, b.ownerID as fownerID, b.friendID as ffriendID from userfriends as a, userfriends as b";
|
private const string userFriendsSelect = "select a.ownerID as ownerID,a.friendID as friendID,a.friendPerms as friendPerms,b.friendPerms as ownerperms, b.ownerID as fownerID, b.friendID as ffriendID from userfriends as a, userfriends as b";
|
||||||
|
|
||||||
|
private const string AvatarPickerAndSQL = "select * from users where username like :username and surname like :surname";
|
||||||
|
private const string AvatarPickerOrSQL = "select * from users where username like :username or surname like :surname";
|
||||||
|
|
||||||
private DataSet ds;
|
private DataSet ds;
|
||||||
private SqliteDataAdapter da;
|
private SqliteDataAdapter da;
|
||||||
private SqliteDataAdapter daf;
|
private SqliteDataAdapter daf;
|
||||||
|
@ -243,41 +246,43 @@ namespace OpenSim.Framework.Data.SQLite
|
||||||
querysplit = query.Split(' ');
|
querysplit = query.Split(' ');
|
||||||
if (querysplit.Length == 2)
|
if (querysplit.Length == 2)
|
||||||
{
|
{
|
||||||
string select = "username like '" + querysplit[0] + "%' and surname like '" + querysplit[1] + "%'";
|
using (SqliteCommand cmd = new SqliteCommand(AvatarPickerAndSQL, g_conn))
|
||||||
lock (ds)
|
|
||||||
{
|
{
|
||||||
DataRow[] rows = ds.Tables["users"].Select(select);
|
cmd.Parameters.Add(new SqliteParameter(":username", querysplit[0] + "%"));
|
||||||
if (rows.Length > 0)
|
cmd.Parameters.Add(new SqliteParameter(":surname", querysplit[1] + "%"));
|
||||||
|
|
||||||
|
using (IDataReader reader = cmd.ExecuteReader())
|
||||||
{
|
{
|
||||||
for (int i = 0; i < rows.Length; i++)
|
while (reader.Read())
|
||||||
{
|
{
|
||||||
Framework.AvatarPickerAvatar user = new Framework.AvatarPickerAvatar();
|
Framework.AvatarPickerAvatar user = new Framework.AvatarPickerAvatar();
|
||||||
DataRow row = rows[i];
|
user.AvatarID = new LLUUID((string) reader["UUID"]);
|
||||||
user.AvatarID = new LLUUID((string) row["UUID"]);
|
user.firstName = (string) reader["username"];
|
||||||
user.firstName = (string) row["username"];
|
user.lastName = (string) reader["surname"];
|
||||||
user.lastName = (string) row["surname"];
|
|
||||||
returnlist.Add(user);
|
returnlist.Add(user);
|
||||||
}
|
}
|
||||||
|
reader.Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (querysplit.Length == 1)
|
else if (querysplit.Length == 1)
|
||||||
{
|
{
|
||||||
string select = "username like '" + querysplit[0] + "%' OR surname like '" + querysplit[0] + "%'";
|
using (SqliteCommand cmd = new SqliteCommand(AvatarPickerOrSQL, g_conn))
|
||||||
lock (ds)
|
|
||||||
{
|
{
|
||||||
DataRow[] rows = ds.Tables["users"].Select(select);
|
cmd.Parameters.Add(new SqliteParameter(":username", querysplit[0] + "%"));
|
||||||
if (rows.Length > 0)
|
cmd.Parameters.Add(new SqliteParameter(":surname", querysplit[0] + "%"));
|
||||||
|
|
||||||
|
using (IDataReader reader = cmd.ExecuteReader())
|
||||||
{
|
{
|
||||||
for (int i = 0; i < rows.Length; i++)
|
while (reader.Read())
|
||||||
{
|
{
|
||||||
Framework.AvatarPickerAvatar user = new Framework.AvatarPickerAvatar();
|
Framework.AvatarPickerAvatar user = new Framework.AvatarPickerAvatar();
|
||||||
DataRow row = rows[i];
|
user.AvatarID = new LLUUID((string) reader["UUID"]);
|
||||||
user.AvatarID = new LLUUID((string) row[0]);
|
user.firstName = (string) reader["username"];
|
||||||
user.firstName = (string) row[1];
|
user.lastName = (string) reader["surname"];
|
||||||
user.lastName = (string) row[2];
|
|
||||||
returnlist.Add(user);
|
returnlist.Add(user);
|
||||||
}
|
}
|
||||||
|
reader.Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue