Reputation: 29314
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.
Upvotes: 0
Views: 136
Reputation: 34054
_close
Closes a previously opened database connection
_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.
And as mentioned in the comments, see this question regarding the out of sync error.
Upvotes: 1