PDA

View Full Version : Only excecute the code when atleast 1 row has been found


thimo
28/07/2013, 06:04 PM
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:

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

MP2
28/07/2013, 06:08 PM
mysql_num_rows? You should really use cache.


new rows, fields;
cache_get_data(rows, fields);

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

thimo
28/07/2013, 06:09 PM
Thank you!

~Edit: do i not need to use mysql_store_result?