Jump to content

closing db connection


jimfog

Recommended Posts

Do you think that whenever I open a db connection I should close it also when I am done with the queries to be performed? Or it depends? Currently I am just making code where queries put user credentials in the db.I am referring in an occasion such as the above.

Link to comment
Share on other sites

how am i going to understand if I use persistent connections or not.Yes I am talking for PHP. You are saying when the script ends.The registration code "resides" in a function-I do not know if this is important, I am just mentioning it.

Link to comment
Share on other sites

You specify a persistent connection when you connect. If you're not sure, then your connections are not persistent. mysql_connect does not open a persistent connection. The mysqli class will open a persistent connection if you specify that in the host name, by default it is not persistent.

Link to comment
Share on other sites

Though connection will be closed at the end of the script it is efficient and good practice to close the connection when you dont need it. if you have quite large processing php file which takes some time to process could make alive the connection. in traffic heavy site which could hit the connection limit provided by shared host.

Link to comment
Share on other sites

. if you have quite large processing php file...
How large is "large"? Give me an example
Link to comment
Share on other sites

"how large" is relative. It is dependable on how many connection/second your host allows, how many request are made per second and how much time it takes to process each file.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...