mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 16:37:01 +00:00
Fixed ticket reading when using PGSQL
Optimized ticket deleting by its position Signed-off-by: ApoC <apoc@nymfe.net>
This commit is contained in:
parent
03621bf5f3
commit
4658b2b38e
2 changed files with 9 additions and 10 deletions
|
|
@ -1950,7 +1950,7 @@ bool ChatHandler::HandleTicketCommand(const char* args)
|
||||||
int num = atoi(px);
|
int num = atoi(px);
|
||||||
if(num > 0)
|
if(num > 0)
|
||||||
{
|
{
|
||||||
QueryResult *result = CharacterDatabase.PQuery("SELECT guid,ticket_text,ticket_lastchange FROM character_ticket ORDER BY ticket_id ASC LIMIT %d,1",num-1);
|
QueryResult *result = CharacterDatabase.PQuery("SELECT guid,ticket_text,ticket_lastchange FROM character_ticket ORDER BY ticket_id ASC "_OFFSET_, num-1);
|
||||||
|
|
||||||
if(!result)
|
if(!result)
|
||||||
{
|
{
|
||||||
|
|
@ -2062,9 +2062,9 @@ bool ChatHandler::HandleDelTicketCommand(const char *args)
|
||||||
// delticket #num
|
// delticket #num
|
||||||
if(num > 0)
|
if(num > 0)
|
||||||
{
|
{
|
||||||
QueryResult *result = CharacterDatabase.PQuery("SELECT ticket_id,guid FROM character_ticket LIMIT %i",num);
|
QueryResult *result = CharacterDatabase.PQuery("SELECT ticket_id,guid FROM character_ticket ORDER BY ticket_id ASC "_OFFSET_,num-1);
|
||||||
|
|
||||||
if(!result || uint64(num) > result->GetRowCount())
|
if(!result)
|
||||||
{
|
{
|
||||||
PSendSysMessage(LANG_COMMAND_TICKENOTEXIST, num);
|
PSendSysMessage(LANG_COMMAND_TICKENOTEXIST, num);
|
||||||
delete result;
|
delete result;
|
||||||
|
|
@ -2072,9 +2072,6 @@ bool ChatHandler::HandleDelTicketCommand(const char *args)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i = 1; i < num; ++i)
|
|
||||||
result->NextRow();
|
|
||||||
|
|
||||||
Field* fields = result->Fetch();
|
Field* fields = result->Fetch();
|
||||||
|
|
||||||
uint32 id = fields[0].GetUInt32();
|
uint32 id = fields[0].GetUInt32();
|
||||||
|
|
|
||||||
|
|
@ -32,9 +32,10 @@
|
||||||
#include "Database/Database.h"
|
#include "Database/Database.h"
|
||||||
#include "Database/DatabasePostgre.h"
|
#include "Database/DatabasePostgre.h"
|
||||||
typedef DatabasePostgre DatabaseType;
|
typedef DatabasePostgre DatabaseType;
|
||||||
#define _LIKE_ "ILIKE"
|
#define _LIKE_ "ILIKE"
|
||||||
#define _TABLE_SIM_ "\""
|
#define _TABLE_SIM_ "\""
|
||||||
#define _CONCAT3_(A,B,C) "( " A " || " B " || " C " )"
|
#define _CONCAT3_(A,B,C) "( " A " || " B " || " C " )"
|
||||||
|
#define _OFFSET_ "LIMIT 1 OFFSET %d"
|
||||||
#else
|
#else
|
||||||
#include "Database/QueryResultMysql.h"
|
#include "Database/QueryResultMysql.h"
|
||||||
#include "Database/QueryResultSqlite.h"
|
#include "Database/QueryResultSqlite.h"
|
||||||
|
|
@ -42,9 +43,10 @@ typedef DatabasePostgre DatabaseType;
|
||||||
#include "Database/DatabaseMysql.h"
|
#include "Database/DatabaseMysql.h"
|
||||||
#include "Database/DatabaseSqlite.h"
|
#include "Database/DatabaseSqlite.h"
|
||||||
typedef DatabaseMysql DatabaseType;
|
typedef DatabaseMysql DatabaseType;
|
||||||
#define _LIKE_ "LIKE"
|
#define _LIKE_ "LIKE"
|
||||||
#define _TABLE_SIM_ "`"
|
#define _TABLE_SIM_ "`"
|
||||||
#define _CONCAT3_(A,B,C) "CONCAT( " A " , " B " , " C " )"
|
#define _CONCAT3_(A,B,C) "CONCAT( " A " , " B " , " C " )"
|
||||||
|
#define _OFFSET_ "LIMIT %d,1"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern DatabaseType WorldDatabase;
|
extern DatabaseType WorldDatabase;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue