How to use the mysql connection in source code?
#1

Hello,

 

i want to make some request in my sources code, but i need to connect to mysql.

 

At the moment, i don't understand that how works the boost mysql query, so i thought to make a simple mysql connection into my code.

 

This is possible?

#2


#include "../ShareLib/DBCmd.h"
   an example with getting ban reasons

bool HWID::BanReasons()
{
CLCString gQuery(1000);
gQuery.Format("SELECT a_reason FROM t_bans");

CDBCmd LCCmd;
LCCmd.Init(&gserver->m_dbdata);
LCCmd.SetQuery(gQuery);
if(!LCCmd.Open())
return false;

m_reason = new int[cmd.m_nrecords];

for(int i = 0; i < LCCmd.m_nrecords; i++)
{
switch(i)
{
case MEMORY_MODIFICATION: // a_reason = 0
m_reason[i] = 0;
case PACKET_SPAM: // a_reason = 1
m_reason[i] = 1;
case FILE_MODIFICATION: // a_reason = 2
m_reason[i] = 2;
}
}
return true;
}

#3

Okay,

 

but the normal C++ api connection working, i'll make with this at the moment, and when i'll get time i'll make with boost lib

 

can be closed



Forum Jump:


Users browsing this thread: 1 Guest(s)