0

I wasn't freeing my statements, as I didn't think it was necessary per se, as the manual says "mysql_free_result() only needs to be called if you are concerned about how much memory is being used for queries that return large result sets." so I didn't. But then I got an error saying: "Commands out of sync; you can't run this command now" which only went away when I freed my results. Weird.

So is it necessary?

Also, what's the difference between close() and free_result()? In PHP's manual they have close used to close statements (in one of the examples on this fetch manual). But they also use free_result here and it's unclear the difference.

4

1 回答 1

1

_close

Closes a previously opened database connection

Documentation

_free_result

Frees the memory associated with a result

Note:

You should always free your result with mysqli_free_result(), when your result object is not needed anymore.

Documentation

And as mentioned in the comments, see this question regarding the out of sync error.

于 2013-02-22T01:04:43.833 回答