do we explicitly need to close connection
mysql_close($link)
or connection is automatically closed after execution of each page.
about closing database connection
Moderator: General Moderators
-
bugthefixer
- Forum Contributor
- Posts: 118
- Joined: Mon Mar 22, 2004 2:35 am
- CoderGoblin
- DevNet Resident
- Posts: 1425
- Joined: Tue Mar 16, 2004 10:03 am
- Location: Aachen, Germany
AS far as I am aware connections should get closed automatically in MySQL, I know this is the case with postgres. However it is good design practice to always ensure it is closed. It is not all that hard to do after all.
Normally you have three layers
<database load and save>
<process>
<output>.
Rather than wait for the output I tend to close the connection after either the database layer (if process does not touch the database which I try to avoid) or after the process layer but before the output.
It is the same with freeResult(). You shouldn't have to do it but it is good practice to.
Normally you have three layers
<database load and save>
<process>
<output>.
Rather than wait for the output I tend to close the connection after either the database layer (if process does not touch the database which I try to avoid) or after the process layer but before the output.
It is the same with freeResult(). You shouldn't have to do it but it is good practice to.