mostafatalebi Posted February 21, 2013 Share Posted February 21, 2013 (edited) Hello everybody I have two questions about mysqli: 1- What does store_result do when it is used in conjunction with bind_result+fetch ? Should it be used? Does using it affects anything? 2- Is it adequate to end you SQL with $Mysql->close or you need to free the result? Thanks in advance Edited February 21, 2013 by mostafatalebi Quote Link to comment https://forums.phpfreaks.com/topic/274799-mysqli-queations/ Share on other sites More sharing options...
kicken Posted February 21, 2013 Share Posted February 21, 2013 1- What does store_result do when it is used in conjunction with bind_result+fetch ? Should it be used? Does using it affects anything? Normally the results of a query are stored on the server. Whenever you fetch() it will ask the server for the next row. The server will then send that row's data over to the script. When you store_result() then the entire result set is copied over to the script and stored in an internal buffer. Then when you fetch() it just pulls the row out of that buffer rather than having the ask the server. Storing the result will cause your script to use more memory as it has to hold the entire set of results. However it also enables things like data seeking and free's up your connection to the server so you can run other queries if needed. 2- Is it adequate to end you SQL with $Mysql->close or you need to free the result? PHP will handle all the cleanup for you when the script ends. Unless your writing a long-running script or a script which will be processing A LOT of data, there isn't generally any need to free the result set manually. Quote Link to comment https://forums.phpfreaks.com/topic/274799-mysqli-queations/#findComment-1414024 Share on other sites More sharing options...
mostafatalebi Posted February 22, 2013 Author Share Posted February 22, 2013 Thanks so much. Very useful. Quote Link to comment https://forums.phpfreaks.com/topic/274799-mysqli-queations/#findComment-1414058 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.