28.03.2016, 15:45
What?
"INSERT INTO player_vehicles VALUES (NULL,%i,%i,%i,%i,%i,%i) ON DUPLICATE KEY UPDATE modelid=%i,color1=%i,color2=%i,paintjob=%i"
forward LoadHouseInfo(); OnGameModeInit { for(new i; i<27; i++) { mysql_format(...); // format the query mysql_tquery(...); // send the query to a forwarded function for(new j; j<20; j++) { mysql_format(...); // format the query mysql_tquery(...); // send the query to a forwarded function } } } public LoadHouseInfo() { // Load house data here if(rows==27) { HouseCreationFunction(0,...); HouseCreationFunction(1,...); HouseCreationFunction(2,...); HouseCreationFunction(3,...); // ... } } HouseCreationFunction() { }
stock pName(playerid)
{
new PlayerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, PlayerName, MAX_PLAYER_NAME);
return PlayerName;
}
orm_addvar_string(playerid, pName(playerid), MAX_PLAYER_NAME, "UserName");
mysql_tquery(mysqlThread, "SELECT * FROM `Vehicles`", "OnVehicleLoading");
new query[128];
format(query, sizeof(query), "SELECT * FROM `players` WHERE `id` = '%d'", Player[playerid][ID]);
mysql_tquery(MySQL, query, "OnStuffSelected", "d", playerid);
public OnStuffSelected(playerid)
{
orm_apply_cache(Player[playerid][ORM_ID], 0);
printf("Player %s has %d Money and is on PosX with %f.", Player[playerid][Name], Player[playerid][Money], Player[playerid][PosX]);
return 1;
}
forward PubTestmysql(); public PubTestmysql() { return 1; } new sdkfsd = 0; forward testsampmV(); public testsampmV() { if (sdkfsd < 500) { for(new i = 0; i < 1000; i++) { format(query, 256, "SELECT * FROM `mybase` WHERE id > 0 LIMIT 1"); mysql_tquery(SQL, query, "PubTestmysql", ""); } sdkfsd++; } } SetTimer("testsampmV",100,true);
format(query, 256, "update `mybase` set cash = 545642 where id = 1");
Memory leak bug on R39-5 and previous version
Test code Код:
forward PubTestmysql(); public PubTestmysql() { return 1; } new sdkfsd = 0; forward testsampmV(); public testsampmV() { if (sdkfsd < 500) { for(new i = 0; i < 1000; i++) { format(query, 256, "SELECT * FROM `mybase` WHERE id > 0 LIMIT 1"); mysql_tquery(SQL, query, "PubTestmysql", ""); } sdkfsd++; } } SetTimer("testsampmV",100,true); Код:
format(query, 256, "update `mybase` set cash = 545642 where id = 1"); |
for(new i = 0; i < cache_get_row_count(); i++)
{
new Cache:result = mysql_query("...");
if(cache_get_row_count())
// stuff
cache_delete(result);
}