tags:

views:

83

answers:

2

Why should I free the result of PHP and MySQL using mysql_free_result()?

And what is the difference whether I free the result or not?

Should I always free the result from a MySQL query result specially in CRUD?

Thanks for answering my questions?

+1  A: 

Freeing results in PHP is more or less to tell both the server and PHP to drop the resultset returned from a query. It is sort of a mean to free up memory especially when you have many queries or queries that return large resultsets.

thephpdeveloper
Thank you for answering my question I'm kinda noob in php development. So its a best practice to free the result query of SELECT statement only? or other statements must also be freed like INSERT and UPDATE? Thank you again.
likeI said, it is more recommended when you have large amount of queries or queies with large result set. otherwise it's perfectly fine.
thephpdeveloper
`INSERT`s and `DELETE`s don't have result sets, so you shouldn't have to free them.
R. Bemrose
A: 

On exit, your script cleans up your results automatically. In a web environment it's only necessary if you've extremely limited memory constraints.

mhughes