mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-16 18:52:22 +00:00
Moved class Bot database code into class BotDatbase
This commit is contained in:
@@ -4134,3 +4134,36 @@ bool ZoneDatabase::DeleteCharacterCorpse(uint32 db_id) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32 ZoneDatabase::LoadSaylinkID(const char* saylink_text, bool auto_insert)
|
||||
{
|
||||
if (!saylink_text || saylink_text[0] == '\0')
|
||||
return 0;
|
||||
|
||||
std::string query = StringFormat("SELECT `id` FROM `saylink` WHERE `phrase` = '%s' LIMIT 1", saylink_text);
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success())
|
||||
return 0;
|
||||
if (!results.RowCount()) {
|
||||
if (auto_insert)
|
||||
return SaveSaylinkID(saylink_text);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto row = results.begin();
|
||||
return atoi(row[0]);
|
||||
}
|
||||
|
||||
uint32 ZoneDatabase::SaveSaylinkID(const char* saylink_text)
|
||||
{
|
||||
if (!saylink_text || saylink_text[0] == '\0')
|
||||
return 0;
|
||||
|
||||
std::string query = StringFormat("INSERT INTO `saylink` (`phrase`) VALUES ('%s')", saylink_text);
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success())
|
||||
return 0;
|
||||
|
||||
return results.LastInsertedID();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user