SA-MP Forums Archive
MySQL Question! - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: MySQL Question! (/showthread.php?tid=341988)



MySQL Question! - Steeve_Smith - 12.05.2012

Hey everybody

I decided to script again yesterday and noticed that the mysql_query has been removed (or changed, nvm).

Tho, I don't know how it works, I also saw that there were a special callback for it, for the threads...

Well, could anybody explain me how mysql_function_query works, or give me a link to a tut?

I don't want people to answer 'this question has been answered multiple times', just some help with that.

Thanks


Re: MySQL Question! - Vince - 12.05.2012

pawn Код:
mysql_function_query(connectionHandle, query[], bool:cache, callback[], format[], {Float,_}:...);



Re : MySQL Question! - Steeve_Smith - 12.05.2012

OK thank you mate

Then, will I be able to use mysql_store_result, mysql_num_rows and mysql_free_result as usual?


Re: MySQL Question! - [BG]PREDATOR - 12.05.2012

Quote:
Originally Posted by Vince
Посмотреть сообщение
pawn Код:
mysql_function_query(connectionHandle, query[], bool:cache, callback[], format[], {Float,_}:...);
  • connectionHandle: returned by mysql_connect (usually 1)
  • query: the query to execute (pre-formatted)
  • cache: enable caching - true/false - only useful for select queries
  • callback: function to call when the query is done (e.g. OnPlayerDataLoaded) - Can be left blank for update queries
  • format for the callback, similar to sscanf. E.g. "ds" - Can also be left blank
  • {Float,_}:...: Parameters to pass to that callback (e.g. playerid, ip) - Can be left blank if no parameters are passed.
Vince can you please explain me how to use it too but wich this example if posible

PHP код:
    new log[156];
    
format(log,sizeof(log),"INSERT INTO `playerlog` (`username`,`status`) VALUES ('%s','Disconnect')",PlayerName(playerid));//playername is my stock for getplayername
    
mysql_query(log); 



Re: Re : MySQL Question! - Vince - 12.05.2012

Quote:
Originally Posted by Steeve_Smith
Посмотреть сообщение
OK thank you mate

Then, will I be able to use mysql_store_result, mysql_num_rows and mysql_free_result as usual?
Yes, but you will need to call it inside the callback given, not right after the query. So like:
pawn Код:
mysql_function_query(connectionHandle, "SELECT * FROM houses", false, "OnLoadHouses", "d", GetTickCount());

forward OnLoadHouses(time);
public OnLoadHouses(time)
{
    mysql_store_result();
    // whatever you need to do
    mysql_free_result();

    printf("time taken: %d ticks", GetTickCount() - time);
    return 1;
}



Re : MySQL Question! - Steeve_Smith - 12.05.2012

OK thank you!