SunQuest
 
           PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old July 6th, 2004, 02:19 PM
nevillemehta nevillemehta is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: India
Posts: 64 nevillemehta User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 44 m 17 sec
Reputation Power: 6
Post Few questions about PHP connection to MySql...

Say, we have a website whose every page involves a connection with a MySql database.

Q1. If we open a connection to the database and retrive some data however forget to close the connection and result set, how bad is that? Disadvantages?

Q2. If we dont close the connection would it be closed automatically when the page exits?

Q3. If most of the pages involve a connection with the database can it be a potential 'advantage' if i dont close the connection and recordset in every page because maybe he saves the time to reconnect or something. (This is just my assumption, please correct me if i am wrong)?

Thank you
Neville

Reply With Quote
  #2  
Old July 7th, 2004, 02:51 AM
kode_monkey kode_monkey is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 367 kode_monkey User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 21 sec
Reputation Power: 6
I think php automatically closes the connection when the script finishes executing otherwise bad scripts would quickly eat resources. If you want someone to establish a permanent connection you can use the mysql_pconnect function instead.

-KM-

Reply With Quote
  #3  
Old July 7th, 2004, 03:28 AM
laidbak laidbak is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Location: In Tha IE -- San Bernardino COUNTY
Posts: 788 laidbak User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 4 m 2 sec
Reputation Power: 7
Send a message via ICQ to laidbak Send a message via AIM to laidbak Send a message via MSN to laidbak Send a message via Yahoo to laidbak
There is really no quick recipie for this, however, a couple things to remember.

1 - PHP closes the mysql connection after the script is done... I would not rely on this as it is not safe to rely on php for this action, nor is it elegant.

2 - If you are connecting to the mysql server locally then there is no problem in making a connection on each request (although, if you can do without a connection that is even better).

3 - pconnect does not solve all your problems. Normally you do not want to use pconnect unless you absolutely have to. In cases where you would have many (more than 20) open tables at one time, you probably don't want to use pconnect.
__________________
__________________________________________________ _
Wil Moore III, MCP | Integrations Specialist | Senior Consultant
Are You Listed...? | DigitallySmooth Inc.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > Few questions about PHP connection to MySql...


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway