MySQL Question!
#1

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
Reply
#2

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.
Reply
#3

OK thank you mate

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

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); 
Reply
#5

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;
}
Reply
#6

OK thank you!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)