SA-MP Forums Archive
About MYSQL - 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: About MYSQL (/showthread.php?tid=547410)



About MYSQL - Fel486 - 22.11.2014

How do I save the value from the query into an array?

PS: using BlueG's mysql plugin.

Example:

PHP код:
new variable;
new 
connection// connection variable
connection mysql_connect(..., ...., ...., ....);
variable mysql_tquery(connection "SELECT `ID` FROM `config` WHERE `ID` = 2); // Misunderstanding that there's a column 



AW: About MYSQL - Mellnik - 22.11.2014

You call cache_get_row from the callback given in mysql_tquery.


Re: About MYSQL - Fel486 - 22.11.2014

Can you give a example? Can't find anything in the official topic.


Re: About MYSQL - Fel486 - 22.11.2014

Anyone?


Re: About MYSQL - ikey07 - 22.11.2014

I would use this
pawn Код:
mysql_query("SELECT `Field1`,`Field2` FROM `table` WHERE `id` = '1'");
 mysql_store_result();
if(mysql_num_rows() > 0)
{
new stat[2][64];
mysql_fetch_field("Field1",stat[0]);
mysql_fetch_field("Field2",stat[1]);
mysql_free_result();
}



Re: About MYSQL - Vince - 22.11.2014

I would not. Stop dwelling in the past.

pawn Код:
new query[128];
mysql_format(connection, query, sizeof(query), "SELECT accountid FROM ... WHERE ...", variables);
mysql_tquery(connection, query, "MyCallback", "d", playerid);

// ---

forward MyCallback(playerid);

public MyCallback(playerid)
{
    if(cache_get_row_count(connection))
    {
        new accountid = cache_get_row_int(0, 0, connection); // row 0, column 0
    }
}
That is the very basic structure you'll need. You can use cache_get_field_content_int to fetch the result by name if you so desire, but it is faster to load it by its numeric position in the result.


Re: About MYSQL - Fel486 - 22.11.2014

Thank everybody!