mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 13:41:31 +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) {
|
void SharedDatabase::GetItemsCount(int32 &item_count, uint32 &max_id) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
|
||||||
MYSQL_RES *result;
|
|
||||||
MYSQL_ROW row;
|
|
||||||
item_count = -1;
|
item_count = -1;
|
||||||
max_id = 0;
|
max_id = 0;
|
||||||
|
|
||||||
char query[] = "SELECT MAX(id), count(*) FROM items";
|
const std::string query = "SELECT MAX(id), count(*) FROM items";
|
||||||
if (RunQuery(query, static_cast<uint32>(strlen(query)), errbuf, &result)) {
|
auto results = QueryDatabase(query);
|
||||||
row = mysql_fetch_row(result);
|
if (!results.Success()) {
|
||||||
if (row != nullptr && row[1] != 0) {
|
LogFile->write(EQEMuLog::Error, "Error in GetItemsCount '%s': '%s'", query.c_str(), results.ErrorMessage().c_str());
|
||||||
item_count = atoi(row[1]);
|
return;
|
||||||
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 (results.RowCount() == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
|
||||||
|
if(row[0])
|
||||||
|
max_id = atoi(row[0]);
|
||||||
|
|
||||||
|
if (row[1])
|
||||||
|
item_count = atoi(row[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SharedDatabase::LoadItems() {
|
bool SharedDatabase::LoadItems() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user