mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-15 04:11:30 +00:00
UpdatePetitionToDB converted to QueryDatabase
This commit is contained in:
parent
e618fe87bd
commit
6364d2c31d
@ -225,46 +225,50 @@ void ZoneDatabase::DeletePetitionFromDB(Petition* wpet) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ZoneDatabase::UpdatePetitionToDB(Petition* wpet) {
|
void ZoneDatabase::UpdatePetitionToDB(Petition* wpet) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
|
||||||
char *query = 0;
|
std::string query = StringFormat("UPDATE petitions SET gmtext = '%s', lastgm = '%s', urgency = %i, "
|
||||||
uint32 affected_rows = 0;
|
"checkouts = %i, unavailables = %i, ischeckedout = %i "
|
||||||
uint8 checkedout = 0;
|
"WHERE petid = %i",
|
||||||
if (wpet->CheckedOut()) checkedout = 1;
|
wpet->GetGMText(), wpet->GetLastGM(), wpet->GetUrgency(),
|
||||||
else checkedout = 0;
|
wpet->GetCheckouts(), wpet->GetUnavails(),
|
||||||
if (!RunQuery(query, MakeAnyLenString(&query, "UPDATE petitions set gmtext = '%s', lastgm = '%s', urgency = %i, checkouts = %i, unavailables = %i, ischeckedout = %i where petid = %i", wpet->GetGMText(), wpet->GetLastGM(), wpet->GetUrgency(), wpet->GetCheckouts(), wpet->GetUnavails(), checkedout, wpet->GetID()), errbuf, 0, &affected_rows)) {
|
wpet->CheckedOut() ? 1: 0, wpet->GetID());
|
||||||
LogFile->write(EQEMuLog::Error, "Error in UpdatePetitionToDB query '%s': %s", query, errbuf);
|
auto results = QueryDatabase(query);
|
||||||
}
|
if (!results.Success())
|
||||||
safe_delete_array(query);
|
LogFile->write(EQEMuLog::Error, "Error in UpdatePetitionToDB query '%s': %s", query.c_str(), results.ErrorMessage().c_str());
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void ZoneDatabase::InsertPetitionToDB(Petition* wpet)
|
void ZoneDatabase::InsertPetitionToDB(Petition* wpet)
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
|
||||||
char *query = 0;
|
|
||||||
uint32 affected_rows = 0;
|
|
||||||
uint8 checkedout = 0;
|
|
||||||
if (wpet->CheckedOut())
|
|
||||||
checkedout = 1;
|
|
||||||
else
|
|
||||||
checkedout = 0;
|
|
||||||
|
|
||||||
uint32 len = strlen(wpet->GetPetitionText());
|
uint32 len = strlen(wpet->GetPetitionText());
|
||||||
char* petitiontext = new char[2*len+1];
|
char* petitiontext = new char[2*len+1];
|
||||||
memset(petitiontext, 0, 2*len+1);
|
memset(petitiontext, 0, 2*len+1);
|
||||||
DoEscapeString(petitiontext, wpet->GetPetitionText(), len);
|
DoEscapeString(petitiontext, wpet->GetPetitionText(), len);
|
||||||
if (!RunQuery(query, MakeAnyLenString(&query, "INSERT INTO petitions (petid, charname, accountname, lastgm, petitiontext, zone, urgency, charclass, charrace, charlevel, checkouts, unavailables, ischeckedout, senttime, gmtext) values (%i,'%s','%s','%s','%s',%i,%i,%i,%i,%i,%i,%i,%i,%i, '%s')", wpet->GetID(), wpet->GetCharName(), wpet->GetAccountName(), wpet->GetLastGM(), petitiontext, wpet->GetZone(), wpet->GetUrgency(), wpet->GetCharClass(), wpet->GetCharRace(), wpet->GetCharLevel(), wpet->GetCheckouts(), wpet->GetUnavails(), checkedout, wpet->GetSentTime(), wpet->GetGMText()), errbuf, 0, &affected_rows)) {
|
|
||||||
LogFile->write(EQEMuLog::Error, "Error in InsertPetitionToDB query '%s': %s", query, errbuf);
|
std::string query = StringFormat("INSERT INTO petitions "
|
||||||
|
"(petid, charname, accountname, lastgm, "
|
||||||
|
"petitiontext, zone, urgency, charclass, "
|
||||||
|
"charrace, charlevel, checkouts, unavailables, "
|
||||||
|
"ischeckedout, senttime, gmtext) "
|
||||||
|
"VALUES (%i, '%s', '%s', '%s', '%s', "
|
||||||
|
"%i, %i, %i, %i, %i, "
|
||||||
|
"%i, %i, %i, %i, '%s')",
|
||||||
|
wpet->GetID(), wpet->GetCharName(), wpet->GetAccountName(), wpet->GetLastGM(),
|
||||||
|
petitiontext, wpet->GetZone(), wpet->GetUrgency(), wpet->GetCharClass(),
|
||||||
|
wpet->GetCharRace(), wpet->GetCharLevel(), wpet->GetCheckouts(), wpet->GetUnavails(),
|
||||||
|
wpet->CheckedOut()? 1: 0, wpet->GetSentTime(), wpet->GetGMText());
|
||||||
|
safe_delete_array(petitiontext);
|
||||||
|
auto results = QueryDatabase(query);
|
||||||
|
if (!results.Success()) {
|
||||||
|
LogFile->write(EQEMuLog::Error, "Error in InsertPetitionToDB query '%s': %s", query.c_str(), results.ErrorMessage().c_str());
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
safe_delete_array(petitiontext);
|
|
||||||
safe_delete_array(query);
|
|
||||||
#if EQDEBUG >= 5
|
#if EQDEBUG >= 5
|
||||||
LogFile->write(EQEMuLog::Debug, "New petition created");
|
LogFile->write(EQEMuLog::Debug, "New petition created");
|
||||||
#endif
|
#endif
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZoneDatabase::RefreshPetitionsFromDB()
|
void ZoneDatabase::RefreshPetitionsFromDB()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user