mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 05:21:29 +00:00
GetItemsCount converted to QueryDatabase
This commit is contained in:
parent
3b75d4fa8f
commit
638d121b75
@ -674,25 +674,26 @@ bool SharedDatabase::GetInventory(uint32 account_id, char* name, Inventory* inv)
|
||||
|
||||
|
||||
void SharedDatabase::GetItemsCount(int32 &item_count, uint32 &max_id) {
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
item_count = -1;
|
||||
max_id = 0;
|
||||
|
||||
char query[] = "SELECT MAX(id), count(*) FROM items";
|
||||
if (RunQuery(query, static_cast<uint32>(strlen(query)), errbuf, &result)) {
|
||||
row = mysql_fetch_row(result);
|
||||
if (row != nullptr && row[1] != 0) {
|
||||
item_count = atoi(row[1]);
|
||||
const std::string query = "SELECT MAX(id), count(*) FROM items";
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
LogFile->write(EQEMuLog::Error, "Error in GetItemsCount '%s': '%s'", query.c_str(), results.ErrorMessage().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
if (results.RowCount() == 0)
|
||||
return;
|
||||
|
||||
auto row = results.begin();
|
||||
|
||||
if(row[0])
|
||||
max_id = atoi(row[0]);
|
||||
}
|
||||
mysql_free_result(result);
|
||||
}
|
||||
else {
|
||||
LogFile->write(EQEMuLog::Error, "Error in GetItemsCount '%s': '%s'", query, errbuf);
|
||||
}
|
||||
|
||||
if (row[1])
|
||||
item_count = atoi(row[1]);
|
||||
}
|
||||
|
||||
bool SharedDatabase::LoadItems() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user