Only excecute the code when atleast 1 row has been found
#1

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

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

Thank you!

~Edit: do i not need to use mysql_store_result?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)