I was looking through my code and read that it was recommened to use mysqli_free_result
when your result object is not needed anymore. But after seeing that each query is outputed to the $result
variable repeatedly throughout the script, I am wondering if mysqli_free_result
would really be necessary. Seems like each time a query is ran the $result
variable is already being wiped clean and set to a new result. Just curious if anyone has any input on this.
Actually it’s necessary, because it might make a heavy load into the server when many requests are made. So preferably, you should use it.
Some other cases when you know that this query is followed by other query so you don’t have to use it.
It’s never strictly necessary, but it's good practice to keep an eye on resources you’re using and know when you don't need them anymore.
It’s pretty minimal effort to drop in that extra line of code, so I would just do it every time you're finished with a result set. It has the added bonus of making it clear to someone reading your code when you’ve finished with a resource.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With