SA-MP Forums Archive
Only excecute the code when atleast 1 row has been found - 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: Only excecute the code when atleast 1 row has been found (/showthread.php?tid=454379)



Only excecute the code when atleast 1 row has been found - thimo - 28.07.2013

Hello,

I am busy on mysql and im trying to figure out on how to do it so it only excecutes code when theres atleast 1 row found. This is my code:
pawn Код:
new string[128];
    new pname_[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pname_, MAX_PLAYER_NAME);
    mysql_real_escape_string(pname_, pname_);
    format(string, sizeof(string), "SELECT `HouseID` FROM `Houses` WHERE `Houseowner`='%s'", pname_);
    mysql_store_result();
    if(mysql_retrieve_row)
        mysql_function_query( Handle, string, true, "OnPlayerHousesLoad", "d", playerid );
But apparently this is not how you use mysql_retrieve_row but i have no idea on how to do it


Re: Only excecute the code when atleast 1 row has been found - MP2 - 28.07.2013

mysql_num_rows? You should really use cache.

pawn Код:
new rows, fields;
cache_get_data(rows, fields);

if(rows >= 1)
{
    // there is at least 1 row
}
else
{
    // No rows
}



Re: Only excecute the code when atleast 1 row has been found - thimo - 28.07.2013

Thank you!

~Edit: do i not need to use mysql_store_result?