jimfog Posted February 18, 2013 Share Posted February 18, 2013 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 More sharing options...
justsomeguy Posted February 18, 2013 Share Posted February 18, 2013 If you're talking about PHP, it will automatically close the connection when the script ends unless you're using persistent connections. Link to comment Share on other sites More sharing options...
jimfog Posted February 18, 2013 Author Share Posted February 18, 2013 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 More sharing options...
justsomeguy Posted February 18, 2013 Share Posted February 18, 2013 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 More sharing options...
birbal Posted February 19, 2013 Share Posted February 19, 2013 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 More sharing options...
jimfog Posted February 19, 2013 Author Share Posted February 19, 2013 . if you have quite large processing php file... How large is "large"? Give me an example Link to comment Share on other sites More sharing options...
birbal Posted February 21, 2013 Share Posted February 21, 2013 "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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now