/    Sign up×
Community /Pin to ProfileBookmark

php mysql connection closes on it’s own?

Hello Mates,
This is basic query. I have read from php.net manual that mysql automatically destroys a connection with php after the script executes. Also a forum member suggested that it is safer to have many opened connection rather than having unnecessary close resource connection code. Can anyone be kind enough to share his/her views on this? I have this php script from where I do open a lot of connections to mysql and only close it while the application logout (I understand mysql just opens one connection for one source in normal scenerio). Is this the worst possible approach? Can I just trust on my hosting ISP’s mysql configuration setting that the connections will be closed automatically, provided they have that setting? Any suggestions would be a great help. Thank you.

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@chazzyMay 07.2008 — for any single "page" that gets executed, you should have 1 connection and only 1 connection to a single DB. there is no reason to have multiple.
Copy linkTweet thisAlerts:
@tkmauthorMay 07.2008 — for any single "page" that gets executed, you should have 1 connection and only 1 connection to a single DB. there is no reason to have multiple.[/QUOTE]
Understood. Thank you.
×

Success!

Help @tkm spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.24,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...