MySQL VS INI?
#6

Quote:
Originally Posted by Vince
View Post
This is for BlueG's plugin, R7 and above:

pawn Code:
// Somewhere
new
    mysqlquery[80];

format(mysqlquery, sizeof(mysqlquery), "SELECT id, money FROM players WHERE name = '%s'", playername);
mysql_function_query(1, mysqlquery, true, "OnPlayerDataLoad", "d", playerid);

// Somewhere else
forward OnPlayerDataLoad(playerid);
public OnPlayerDataLoad(playerid)
{
    new
        rows,
        fields;

    cache_get_data(1, rows, fields);

    if(rows)
    {
        new temp[12];
        cache_get_row(0, 0, temp); PlayerInfo[playerid][pSQLID] = strval(temp);
        cache_get_row(0, 1, temp); PlayerInfo[playerid][pMoney] = strval(temp);
    }
    return;
}
And how do I connect? I have the following in OnGameModeInit()
pawn Code:
mysql_debug(ENABLE_DEBUGGING);
g_ConnectionHandle = mysql_connect("host", "user", "database", "password"); //with my real info of course
and the sample gamemode shows them using "g_ConnectionHandle" infront of every query, EX: (from sample GM)
pawn Code:
new szPlayerIP[16], iNumIP, szQuery[128];
GetPlayerIp(playerid, szPlayerIP, sizeof(szPlayerIP));
iNumIP = IpToInteger(szPlayerIP);
mysql_format(g_ConnectionHandle, szQuery, "SELECT `country_code`, `country_name` FROM `ip2c` WHERE \"%d\" BETWEEN `begin_ip_num` AND `end_ip_num` LIMIT 1", iNumIP);
mysql_function_query(g_ConnectionHandle, szQuery, true, "onCountryDetect", "ds", playerid, szPlayerIP);
See how they use "g_ConnectionHandle" infront of the queries? Is that just the "mysqlquery" you used?
Reply


Messages In This Thread
MySQL VS INI? - by Nathan_Taylor - 28.02.2013, 15:56
Re: MySQL VS INI? - by Vince - 28.02.2013, 16:14
Re: MySQL VS INI? - by Nathan_Taylor - 28.02.2013, 16:17
Re: MySQL VS INI? - by Vince - 28.02.2013, 18:01
Re: MySQL VS INI? - by Nathan_Taylor - 28.02.2013, 18:07
Re: MySQL VS INI? - by Nathan_Taylor - 28.02.2013, 19:06
Re: MySQL VS INI? - by Yves - 28.02.2013, 19:09
Re: MySQL VS INI? - by Djole1337 - 28.02.2013, 19:16
Re: MySQL VS INI? - by Nathan_Taylor - 28.02.2013, 19:19
Re: MySQL VS INI? - by Djole1337 - 28.02.2013, 19:24

Forum Jump:


Users browsing this thread: 4 Guest(s)