SA-MP Forums Archive
Two MySQL functions - 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: Two MySQL functions (/showthread.php?tid=302279)



Two MySQL functions - Tee - 08.12.2011

Well the two functions are 'mysql_store_result();' and 'mysql_free_result();'

I've heard many people saying that if no result was found, then it doesn't make sense to use 'mysql_free_result'.
Here's an example:

pawn Код:
for(new i = 1; i<MAX; i++)
        {
            format(String,sizeof(String),"SELECT `ID` FROM table WHERE `ID` = %d LIMIT 1",i);
            mysql_query(String);
            mysql_store_result();
            if(mysql_num_rows() == 0)
            {
                mysql_free_result();
                continue;
            }
            if(mysql_num_rows() != 0)
            {
                //do something
                mysql_free_result();
            }
        }
I want to know if it's correct to use 'mysql_free_result();' within 'if(mysql_num_rows() == 0);'


Re: Two MySQL functions - xMichaelx - 08.12.2011

Basically you are freeing you result, it should only be where a mysql_store_result is, read through [HiC]TheKiller's tut on "Create A MySQL System"