Are mysql_close and pg_close required?

Possible duplicate:
using mysql_close ()

Are mysql_close and pg_close required?

In some script, no ... why?

What happens if I do not use it?

+4
source share
4 answers

If you do not call this, the socket connection to the database remains open for ~ 30 seconds in the standby state.

If you get many, many people, and you are not able to reuse these connections with zombies in any way, your database may explode with too much user error.

So, the answer to your question is: it is not syntactically required, but it is very bad practice not to include them.

+3
source

Why don't you read it in the PHP reference manual? All information is ...

But in a nutshell: no, they are not needed, but IMHO it is better to close the connections themselves to free up resources when you no longer need them.

+4
source

You do not explicitly publish resources, but rely on server-side timeouts and application-side internal work.

+1
source

PHP will close any open connection at the end of execution. Thus, nothing happens if you do not put it.

See http://www.php.net/manual/en/function.mysql-close.php

The use of mysql_close () is usually not required, as mutable open links automatically close at the end of the script.

+1
source

Source: https://habr.com/ru/post/1312192/


All Articles