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

Edited by mostafatalebi
Link to comment
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.