Current location: Hot Scripts Forums » Other Discussions » Database » MySQL - connect more than once in a page or one connection?


MySQL - connect more than once in a page or one connection?

Reply
  #1 (permalink)  
Old 02-22-08, 10:37 AM
j-a-m-i-n's Avatar
j-a-m-i-n j-a-m-i-n is offline
Newbie Coder
 
Join Date: Oct 2006
Posts: 85
Thanks: 0
Thanked 1 Time in 1 Post
MySQL - connect more than once in a page or one connection?

Hi,

Just wanted to gather some opinions on whether it's bad practice to open and close connections to the database more than once in one php file?

Should I just open the connection once and close it once?

Will this considerably affect page load time?

It's just that I have a news system in which I want to develop a 'headline manager' for managing news articles displayed on the homepage.

This means i will have say (higher up on the page) the very latest database entry and further down the next 4 entries.

Would it be best to open and close the connection for the latest entry query and then open up the connection again further down?

Thanks for your time,
Ben
Reply With Quote
  #2 (permalink)  
Old 02-25-08, 03:02 PM
TheDemoSite TheDemoSite is offline
Newbie Coder
 
Join Date: Sep 2004
Location: in a database!
Posts: 28
Thanks: 1
Thanked 0 Times in 0 Posts
I would not close a connection if there was any chance of using it again before the script ended.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP syntax error stuckonaproject ASP 8 12-14-04 10:30 AM
master detail page, no DSN connection slglassett ASP 3 07-27-04 01:20 PM
page browsing problem mivec PHP 3 04-17-04 03:43 AM
Error while creating database (Errornumber 2002: "Can't connect to local MySQL server lylesback2 PHP 5 04-11-04 01:37 PM
Can't connect to local MySQL ERROR Abdul PHP 1 03-27-04 02:43 PM


All times are GMT -5. The time now is 05:02 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.