open.mp forum
[Pawn] mysql_query to tquery inline - Printable Version

+ open.mp forum (https://forum.open.mp)
-- Forum: SA-MP (https://forum.open.mp/forumdisplay.php?fid=3)
--- Forum: Pawn Scripting (https://forum.open.mp/forumdisplay.php?fid=10)
--- Thread: [Pawn] mysql_query to tquery inline (/showthread.php?tid=1936)



mysql_query to tquery inline - Zow - 2021-04-23

this one work



Code:
GetVehicleCount(playerid)

{

? ? new threadCheck[128], count;



? ? mysql_format(ourConnection, threadCheck, sizeof(threadCheck), "SELECT COUNT(*) FROM vehicles WHERE VehicleOwnerDBID = %d", PlayerInfo[playerid][pDBID]);

? ? new Cache: result = mysql_query(ourConnection, threadCheck);



? ? cache_get_value_index_int(0, 0, count);



? ? cache_delete(result);

? ? return count;

}



this is first time to using inline but its not work as I expect



Code:
GetVehicleCountEx(playerid) {

? ? new count;

? ? inline _CountVehicle()

? ? {

? ? ? ? new rows;

? ? ? ? if(cache_get_row_count(rows))

? ? ? ? {

? ? ? ? ? ? cache_get_value_index_int(0, 0, count);

? ? ? ? }

? ? }

? ? MySQL_TQueryInline(ourConnection, using inline _CountVehicle, "SELECT COUNT(*) FROM vehicles WHERE VehicleOwnerDBID = %d", PlayerInfo[playerid][pDBID]);

? ? return count;

}



RE: mysql_query to tquery inline - Awide - 2021-04-24

Your syntax might be incorrect. I think you can't format the string in that function, you need to format it earlier.



Check this:



Code:
new query[1024];

mysql_format(ourConnection, query, sizeof query, "SELECT COUNT(*) FROM vehicles WHERE VehicleOwnerDBID = %d", PlayerInfo[playerid][pDBID]);

inline LoadData() {

new rows;

? ? ? ? if(cache_get_row_count(rows)) {

? ? ? ? ? ? cache_get_value_index_int(0, 0, count);

? ? ? ? }

@return 1;

}

MySQL_TQueryInline(ourConnection, using inline LoadData, query);





Also note tquery is not happening instantly! If you need the data immediately to be handled by a function use non-threaded queries.