INTERVIEW QUESTIONS
PROGRAMMING LANGUAGES
PHP
DETAILS
Question: What is difference between mysql_connect and mysql_pconnect
Answer: 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.
|
Question:
What is difference between mysql_connect and mysql_pconnect
Answer:
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. Source: CoolInterview.com
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. Source: CoolInterview.com
Answered by: modi | Date: 1/30/2009
| 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. Source: CoolInterview.com
Answered by: shashi bhushan | Date: 10/3/2009
| Contact shashi bhushan
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|