• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pawn] [Help]How to retrieve data from mysql.
#1
I get how to send data and so on, but when it comes to retrieve the data i cant get my head arround it, i see that it uses cache and so on, can somebody explain me how do I?retrieve data successfully??



thanks
  Reply
#2
Non-threaded query:

Code:
new Cache: result = mysql_query(ConnectionHandle, "SELECT * FROM `accounts` WHERE `ID` = '10'");

new dest[24], score;

if (cache_num_rows())
{

    cache_get_value_name(0, "Nick", dest, 24);

    cache_get_value_name_int(0, "Score", score);

}

cache_delete(result);



(Recommended) Threaded query:

Code:
mysql_tquery(ConnectionHandle, "SELECT * FROM `accounts` WHERE `ID` = '10'", "OnPlayerDataLoaded", "i", playerid);


forward OnPlayerDataLoaded(playerid);
public OnPlayerDataLoaded(playerid)
{
    if (!cache_num_rows()) {
        return 0;
    }

    new dest[24], score;

    cache_get_value_name(0, "Nick", dest, 24);

    cache_get_value_name_int(0, "Score", score);

    return 1;

}
  Reply
#3
(2021-01-25, 11:42 AM)Radical Wrote: Non-threaded query:

Code:
new Cache: result = mysql_query(ConnectionHandle, "SELECT * FROM `accounts` WHERE `ID` = '10'");

new dest[24], score;

if (cache_num_rows())

{

? ? cache_get_value_name(0, "Nick", dest, 24);

? ? cache_get_value_name_int(0, "Score", score);

}

cache_delete(result);



Threaded query:

Code:
mysql_tquery(ConnectionHandle, "SELECT * FROM `accounts` WHERE `ID` = '10'", "OnPlayerDataLoaded", "i", playerid);



forward?OnPlayerDataLoaded(playerid);

public OnPlayerDataLoaded(playerid) {

? ??if (!cache_num_rows())?

? ? ? ? return 0;



? ? new dest[24], score;



? ? cache_get_value_name(0, "Nick", dest, 24);

? ? cache_get_value_name_int(0, "Score", score);

? ? return 1;

}



Thanks alot!
  Reply


Forum Jump: