Jump to content

MYSQLI Queations


mostafatalebi

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/274799-mysqli-queations/
Share on other sites

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.

 

 

Link to comment
https://forums.phpfreaks.com/topic/274799-mysqli-queations/#findComment-1414024
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.