20.07.2014, 14:58
Updating from R5-6-7 to R39-2 require a lot of modifications : the syntax of natives has changed, most of the natives of R5-6-7 were removed and replaced by better/faster/easier equivalents.
COMMAND:bstorage(playerid, params[])
{
new tBID, tRID, query[100], string[256];
if(sscanf(params, "d", tBID)){ return SendClientMessage(playerid, -1, "USAGE:\"/bstorage [Business IDl]\""); }
mysql_format(mysql, query, sizeof(query), "SELECT * from `businesses_storage` where `BID` = '%d'", tBID);
mysql_query(mysql, query);
if(cache_num_rows())
{
for(new i = 0; i<cache_num_rows(); i++)
{
tRID = cache_get_field_content_int(i, "RID", mysql);
format(string, sizeof(string), "RID: %d - %s", tRID, GetResourceName(tRID));
SCM(playerid, -1, string);
}
}
return 1;
}
stock GetResourceName(RID)
{
new
query[100],
tempName[24];
mysql_format(mysql2, query, sizeof(query), "SELECT `Name` FROM `resources` WHERE `ID` = '%d'", RID);
mysql_query(mysql2, query);
if(cache_num_rows())
{
cache_get_field_content(0, "Name", tempName, mysql2);
}
return tempName;
}
COMMAND:bstorage(playerid, params[]) { new tBID, tRID, query[100], string[256]; if(sscanf(params, "d", tBID)){ return SendClientMessage(playerid, -1, "USAGE:\"/bstorage [Business IDl]\""); } mysql_format(mysql, query, sizeof(query), "SELECT * from `businesses_storage` where `BID` = '%d'", tBID); new Cache:res1 = mysql_query(mysql, query); //res1 is now the active cache here for(new i = 0; i < cache_num_rows(); i++) { tRID = cache_get_field_content_int(i, "RID"); format(string, sizeof(string), "RID: %d - %s", tRID, GetResourceName(tRID)); SCM(playerid, -1, string); //the cache in your function "GetResourceName" overwrote our "res1" cache, //we need to manually set "res1" as the active cache now cache_set_active(res1); } cache_delete(res1); return 1; } stock GetResourceName(RID) { new query[100], tempName[24]; mysql_format(mysql, query, sizeof(query), "SELECT `Name` FROM `resources` WHERE `ID` = '%d'", RID); new Cache:result = mysql_query(mysql, query); //result is now the active cache here, overwriting any previously active cache if(cache_num_rows()) { cache_get_field_content(0, "Name", tempName); } cache_delete(result); //result has been deleted, there is now no active cache return tempName; }
Failed (libmysqlclient_r.so.15: cannot open shared object file: No such file or directory)
Step 1:- wget http://downloads.mysql.com/archives/mysq...097672Step 2:- rpm -qlp MySQL-shared-compat-5.1.49-1.rhel5.i386.rpm
Hello, I've got 2 questions.
First, what is the difference between mysql_pquery() and mysql_tquery()? In wiki it says both are multithreaded. Secoond, What is field id? Is it a column of result set? How do you know field ID of result set? |
1. I've also asked that question few months ago, http://forum.sa-mp.com/converse.php?u=96478&u2=96708
2. Detail about how MySQL uses indexes: http://dev.mysql.com/doc/refman/4.1/...l-indexes.html Use cache_get_field_count to get the field count from the current result set. If you're going to use cache_get_row_*, field index always starts from 0. |
[04:08:36] [DEBUG] mysql_tquery - connection: 1, query: "SELECT * FROM `voitures`", callback: "(null)", format: "(null)" [04:08:36] [DEBUG] cache_get_row_count - connection: 1 [04:08:36] [WARNING] cache_get_row_count - no active cache
public SauvegardeVoitures() { new query[128]; format(query, sizeof(query), "SELECT * FROM `voitures`"); mysql_tquery(mysql, query, ""); new nbVoitures = cache_get_row_count(); printf("Dйbut save v, nbVoitures = %d", nbVoitures); if(nbVoitures > 0) { for(new v = 1; v < nbVoitures; v++) { SauvegardeVoiture(v); printf("Save veh: %d", v); } } return 1; }
forward myCallback();
public myCallback()
{
new count = cache_get_row_count();
// etc
}
// in some function
mysql_tquery(1, "SELECT * FROM myTable", "myCallback");
mysql_tquery(1, "SELECT * FROM myTable");
new count = cache_get_row_count();
// etc