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