Skip to content

Commit

Permalink
Fixing the weird mysql statements
Browse files Browse the repository at this point in the history
  • Loading branch information
fr34kyn01535 committed May 13, 2019
1 parent 4cfbf53 commit e02d0bd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions DatabaseManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ public List<PlayerData> QueryByName(string playerName, QueryType queryType, out
MySqlDataReader reader = null;
totalRecods = 0;
uint limitStart = (page - 1) * limit;
MySqlCommand command = Connection.CreateCommand();
try
{
if (!Initialized)
Expand All @@ -429,7 +430,6 @@ public List<PlayerData> QueryByName(string playerName, QueryType queryType, out
return playerList;
}

MySqlCommand command = Connection.CreateCommand();
command.Parameters.AddWithValue("@name", "%" + playerName + "%");
command.Parameters.AddWithValue("@instance", InstanceID);
string type;
Expand All @@ -452,8 +452,8 @@ public List<PlayerData> QueryByName(string playerName, QueryType queryType, out
break;
}
if (pagination)
command.CommandText = "SELECT IFNULL(Count(a.steamid),0) AS count FROM `" + Table + "` AS a LEFT JOIN `" + TableServer + "` AS b ON a.steamid = b.steamid WHERE ( b.serverid = @instance OR b.serverid = a.lastserverid OR b.serverid IS NULL ) " + type + " GROUP BY a.steamid";
command.CommandText += "SELECT a.steamid, a.steamname, a.charname, a.ip, a.lastloginglobal, a.totalplaytime, a.lastserverid, b.serverid, b.lastloginlocal, b.cleanedbuildables, b.cleanedplayerdata, c.servername AS LastServerName FROM `" + Table + "` AS a LEFT JOIN `" + TableServer + "` AS b ON a.steamid = b.steamid LEFT JOIN `" + TableInstance + "` AS c ON a.lastserverid = c.serverid WHERE (b.serverid = @instance OR b.serverid = a.lastserverid OR b.serverid IS NULL ) AND ( a.steamname LIKE @name OR a.charname LIKE @name ) ORDER BY a.lastloginglobal DESC LIMIT 0, 10; ";
command.CommandText = "SELECT IFNULL(Count(a.steamid),0) AS count FROM `" + Table + "` AS a LEFT JOIN `" + TableServer + "` AS b ON a.steamid = b.steamid WHERE ( b.serverid = @instance OR b.serverid = a.lastserverid OR b.serverid IS NULL ) " + type + " GROUP BY a.steamid;";
command.CommandText += "SELECT a.steamid, a.steamname, a.charname, a.ip, a.lastloginglobal, a.totalplaytime, a.lastserverid, b.serverid, b.lastloginlocal, b.cleanedbuildables, b.cleanedplayerdata, c.servername AS LastServerName FROM `" + Table + "` AS a LEFT JOIN `" + TableServer + "` AS b ON a.steamid = b.steamid LEFT JOIN `" + TableInstance + "` AS c ON a.lastserverid = c.serverid WHERE (b.serverid = @instance OR b.serverid = a.lastserverid OR b.serverid IS NULL ) " + type + " ORDER BY a.lastloginglobal DESC LIMIT 0, 10; ";
reader = command.ExecuteReader();
if (pagination)
{
Expand All @@ -480,7 +480,7 @@ public List<PlayerData> QueryByName(string playerName, QueryType queryType, out
}
catch (MySqlException ex)
{
HandleException(ex);
HandleException(ex, "Failed to execute: "+ command.CommandText);
}
finally
{
Expand Down

0 comments on commit e02d0bd

Please sign in to comment.