CoolInterview.com - World's Largest Collection of Interview Questions
Send Free SMS
 Interview Questions  
 Our Services  


INTERVIEW QUESTIONS LANGUAGES PHP DETAILS
Question :
what is difference between mysql_connect and mysql_pconnect





Category PHP Interview Questions
Rating (2.3) By 3 users
Added on 7/19/2006
Views 1301
Rate it!
Answers:

Mysql_connect opens up a database connection every time a page is loaded. mysql_pconnect opens up a connection, and keeps it open across multiple requests.

Mysql_pconnect uses less resources, because it does not need to establish a database connection every time a page is loaded.




mysql_connect opens a normal connections to mysql database.

mysql_pconnect opens a persistent connection i.e. if there is any connection open in the script it will use that connection only and not making a new connection each time.At very high traffic environment mysql_connect provides better performance.



 Posted by: modi    

Contact modi  Contact modi

Mysql_connect opens a new connection each time a PHP page is called up, and closes the connection down again at the end of the request. It's ideal for pages that don't have a heavy usage - doesn't need tuning, is straightforward internally. If you compare MySQL to a shop, this is the connection that you would use for a small shop where the door is opened each time a new customer wishes to enter.

Mysql_pconnect will also open a new connection when a PHP page is called up (at any rate, it will the first time after a server reboot), but it will NOT close the connection at the end of the request - instead, it will save it in a connection pool so that a subsequent request can continue to use the same connection. It's intended for pages that do have a heavy usage - where the resources burn up by opening and closing connections every time might have a severe effect on performance. If your local supermarket had a door that was opened each time someone went in and out, there would be a lot of needless opening and closing going on - better to leave it open and let a whole lot of people in and out at the same time.



 Posted by: shashi bhushan    

Contact shashi bhushan  Contact shashi bhushan


If you have the better answer, then send it to us. We will display your answer after the approval.
Name :*
Email Id :*
Answer :*
Verification Code Code Image - Please contact webmaster if you have problems seeing this image code Not readable? Load New Code
Process Verification  Enter the above shown code:*
Inform me about updated answers to this question

   
Related Questions
View Answer
What is the difference between echo and print statement?

View Answer
How i can make a chat page in php in simple

View Answer
what is difference between mysql_fetch_array(),mysql_fetch_row() and mysql_fetch_object()
please insert with example.

View Answer
How can I maintain the count of how many persons have hit my site?

View Answer

Please Note: We keep on updating better answers to this site. Subscribe to our newsletter to get notified when better answer is posted.

Notify me when better answer is posted!
Email:

View ALL PHP Interview Questions

User Options
Sponsored Links


Copyright ©2003-2010 CoolInterview.com, All Rights Reserved.
Privacy Policy | Terms and Conditions
Page URL: http://www.coolinterview.com/interview/6173/default.asp?cachecommand=bypass


Download Yahoo Messenger | Placement Papers| FREE SMS | ASP .Net Tutorial | Web Hosting | Free SMS | Dedicated Servers | Joke of the Day

0.66