Skip to content

Commit e02d0bd

Browse files
committed
Fixing the weird mysql statements
1 parent 4cfbf53 commit e02d0bd

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

DatabaseManager.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,7 @@ public List<PlayerData> QueryByName(string playerName, QueryType queryType, out
411411
MySqlDataReader reader = null;
412412
totalRecods = 0;
413413
uint limitStart = (page - 1) * limit;
414+
MySqlCommand command = Connection.CreateCommand();
414415
try
415416
{
416417
if (!Initialized)
@@ -429,7 +430,6 @@ public List<PlayerData> QueryByName(string playerName, QueryType queryType, out
429430
return playerList;
430431
}
431432

432-
MySqlCommand command = Connection.CreateCommand();
433433
command.Parameters.AddWithValue("@name", "%" + playerName + "%");
434434
command.Parameters.AddWithValue("@instance", InstanceID);
435435
string type;
@@ -452,8 +452,8 @@ public List<PlayerData> QueryByName(string playerName, QueryType queryType, out
452452
break;
453453
}
454454
if (pagination)
455-
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";
456-
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; ";
455+
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;";
456+
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; ";
457457
reader = command.ExecuteReader();
458458
if (pagination)
459459
{
@@ -480,7 +480,7 @@ public List<PlayerData> QueryByName(string playerName, QueryType queryType, out
480480
}
481481
catch (MySqlException ex)
482482
{
483-
HandleException(ex);
483+
HandleException(ex, "Failed to execute: "+ command.CommandText);
484484
}
485485
finally
486486
{

0 commit comments

Comments
 (0)