mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 17:51:28 +00:00
GetBook converted to QueryDatabase
This commit is contained in:
parent
2a73a572d3
commit
0ef428d286
@ -1015,36 +1015,29 @@ const Item_Struct* SharedDatabase::IterateItems(uint32* id) {
|
||||
|
||||
std::string SharedDatabase::GetBook(const char *txtfile)
|
||||
{
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
char *query = 0;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
char txtfile2[20];
|
||||
std::string txtout;
|
||||
strcpy(txtfile2, txtfile);
|
||||
if (!RunQuery(query, MakeAnyLenString(&query, "SELECT txtfile FROM books where name='%s'", txtfile2), errbuf, &result)) {
|
||||
std::cerr << "Error in GetBook query '" << query << "' " << errbuf << std::endl;
|
||||
if (query != 0)
|
||||
safe_delete_array(query);
|
||||
|
||||
std::string query = StringFormat("SELECT txtfile FROM books WHERE name = '%s'", txtfile2);
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
std::cerr << "Error in GetBook query '" << query << "' " << results.ErrorMessage() << std::endl;
|
||||
txtout.assign(" ",1);
|
||||
return txtout;
|
||||
}
|
||||
else {
|
||||
safe_delete_array(query);
|
||||
if (mysql_num_rows(result) == 0) {
|
||||
mysql_free_result(result);
|
||||
|
||||
if (results.RowCount() == 0) {
|
||||
LogFile->write(EQEMuLog::Error, "No book to send, (%s)", txtfile);
|
||||
txtout.assign(" ",1);
|
||||
return txtout;
|
||||
}
|
||||
else {
|
||||
row = mysql_fetch_row(result);
|
||||
|
||||
auto row = results.begin();
|
||||
txtout.assign(row[0],strlen(row[0]));
|
||||
mysql_free_result(result);
|
||||
|
||||
return txtout;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SharedDatabase::GetFactionListInfo(uint32 &list_count, uint32 &max_lists) {
|
||||
list_count = 0;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user