mysql_connect() and mysql_pconnect()

A

Anonymous

Guest
Hello everyone,

I feel confused when to use mysql_pconnect() instead of mysql_connect().

I will apreciate if someone can give me an example about that.

thanks
 
This will help you:

mysql_connect -- Open a connection to a MySQL Server
mysql_pconnect -- Open a persistent connection to a MySQL server
 
CrazyEye said:
mysql_connect -- Open a connection to a MySQL Server
mysql_pconnect -- Open a persistent connection to a MySQL server

Thankyou, captain obvious.. :roll:
 
Thanks swirlee,

I read that chapter before and I undertand the diference between both.
I think what I need is like a real life example.

I've been playing with php and mysql for not too long, and I have always used myslq_connect() because that is what I learned from some code I saw. I ran into mysql_pconnect() a few days ago and I've been wondering if i should use it in my applications instead of mysql_connect(). What I don't know is when would you want to have a persistent connection.
 
The relevant paragraph is this one:

If persistent connections don't have any added functionality, what are they good for?

The answer here is extremely simple -- efficiency. Persistent connections are good if the overhead to create a link to your SQL server is high. Whether or not this overhead is really high depends on many factors. Like, what kind of database it is, whether or not it sits on the same computer on which your web server sits, how loaded the machine the SQL server sits on is and so forth. The bottom line is that if that connection overhead is high, persistent connections help you considerably.

I honestly don't think I can give you a better answer than that.
 
Back
Top