02.08.2014, 18:11
Just a quick question regarding multiple queries, had a look but with 500 pages and the search not giving me a lot of advice, thought I would just ask!
I've got a command that finds storage located in businesses and once I have the ID of the storage, I run another query to get the name of the resource that is stored inside of the storage:
It sort of works, but it only returns the first result:
However if I remove the GetResourceName from the format line it returns:
I have the two different mysql connections and run both of the queries on the different connections. I have also made sure that they are using different connection IDs.
Any ideas?
I've got a command that finds storage located in businesses and once I have the ID of the storage, I run another query to get the name of the resource that is stored inside of the storage:
pawn Code:
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;
}
However if I remove the GetResourceName from the format line it returns:
I have the two different mysql connections and run both of the queries on the different connections. I have also made sure that they are using different connection IDs.
Any ideas?