Jump to content

Select value in DB c++


Recommended Posts

  • Premium
1 hour ago, ridetpro said:

std::unique_ptr<SQLMsg> pSelectMsg(DBManager::instance().DirectQuery("SELECT infernus FROM player.player WHERE name='%s'", GetName());
BYTE count = pSelectMsg->Get()->uiNumRows;

if (count >= 3)
	ChatPacket(CHAT_TYPE_INFO,"Total count is %d", count);

 

That way, count is allways "1"   :(

 

that way do not get invernus table value

if pc.get_sex() == true and npc.get_sex() == false then
	npc.purge()
end

 

Link to comment
Share on other sites

char szQuery[QUERY_MAX_LEN];
snprintf(szQuery, sizeof(szQuery), "SELECT infernus FROM player.player WHERE name='%s'", GetName());
std::unique_ptr<SQLMsg> pSelectMsg(DBManager::instance().DirectQuery(szQuery);

SQLResult* pRes = pSelectMsg->Get();
	
if (pRes->uiNumRows > 0)
{
	MYSQL_ROW row = mysql_fetch_row(pRes->pSQLResult);
		
	DWORD GetVal = 0;
	str_to_number(GetVal, row[0]);

	ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Total count is %d"), GetVal);
}

It should work now. 

  • Love 2
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.