Page 1 of 1

Use mysql_connect or mysql_pconnect?

Posted: Sun Oct 07, 2007 10:06 am
by PhpMachine
Hi

Let us say you have a website where you, in a lot of different classes, connect to your database to
retrieve/update information.

Should you then use mysql_connect or mysql_pconnect?
Or should you only once (for instance in "index.php"), create the connection, and then pass that link
to all classes that need to work with the database?

What are the advantages and disadvantages using mysql_connect, mysql_pconnect?

Posted: Sun Oct 07, 2007 10:11 am
by s.dot
Persistent connections will persist until you explicitly close them. In my opinion, not good for high traffic web sites or sites with lots of readable content. (why would you want your database connection open for X minutes while user is reading)

Posted: Sun Oct 07, 2007 11:54 am
by Christopher
Yes, I would recommend using mysql_connect until you find that you actually need persistent connections (which you probably won't).

Posted: Sun Oct 07, 2007 12:21 pm
by PhpMachine
When do you actually need persistent connections?

Posted: Sun Oct 07, 2007 2:31 pm
by feyd
PhpMachine wrote:When do you actually need persistent connections?
Generally, you don't, ever.