Do I really need to do mysql_close()? Why or why not?
Is there a trigger that closes the link after mysql_connect even if I don’t do mysql_close?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In most cases calling
mysql_closewill not make any difference, performance-wise. But it’s always good practice to close out resources (file handles, open sockets, database connections, etc.) that your program is no longer using.This is especially true if you’re doing something that may potentially take a few seconds – for instance, reading and parsing data from a REST API. Since the API call is going over the line, negative network conditions can cause your script to block for several seconds. In this case, the appropriate time to open the database connection is after the REST call is completed and parsed.
To sum up my answer, the two big rules are: