In the first code example on this page, this is the second last function called.
The comment says it frees the result set, but I am not able to understand what exactly is meant by freeing a result set? The result set is an Object so what is meant by freeing it?
/* free result set */
$result->free();
The creation of a result set is a form of dynamic memory allocation, almost certainly done when an SQL query was executed, something like:
$conn = some_connection_to_database();
$rows = $conn->query("select name from etc_passwd where group = 'admin'")
Since the intent is for you to then use that result set, it cannot be freed as part of the query itself.
So, once the query is run and the result set is returned, you are responsible for freeing that memory when you're done with it.
That is where free() will be used. The basic idea (in English) is:
free bit).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