views:

1758

answers:

6

Hi, I am planning to use MYSQL. Is there a connection pooling extension available. or what is the normal practice for connection. is this the one used in every where... mysqli_connect("localhost", "xxx", "xxx", "test");

Do people use just normal msql_connect or pconnect..? how better is pconnect and what setting should I do for PConnect....

THnks

A: 

mysqli_connect is the recommended method.
mysqli_pconnect will persist the connection (i.e. use connection pooling).
Are you sure you need pooling?

Itay Moav
I am not sure. I think the connection pooling will increase the performance as it doesn't request a connect every time. what do you suggest...
coool
It really depends on your site. Can't tell you in the air what is better. B.T.W do not use the mysql_ functions but rather the mysqli_ functions, as they are the recommended ones (search mysql site).
Itay Moav
A: 

Badly asked question

mysql_pconnect() or mysqli_pconnect()

http://uk.php.net/manual/en/function.mysql-pconnect.php

James C
+4  A: 

have you ever used mysql_pconnect() ? mysql_pconnect() acts very much like mysql_connect() with two major differences.

First, when connecting, the function would first try to find a (persistent) link that's already open with the same host, username and password. If one is found, an identifier for it will be returned instead of opening a new connection.

Second, the connection to the SQL server will not be closed when the execution of the script ends. Instead, the link will remain open for future use (mysql_close() will not close links established by mysql_pconnect()).

This type of link is therefore called 'persistent'

Check it here

Adinochestva
A: 

There are 3 connection functions:

mysql_connect: normal connection, no pooling, you cannot execute stored procedures (just sql)

mysql_pconnect: pooled connection, you cannot execute stored procedures (just sql)

mysqli_connect: normal connection, no pooling, you can execute stored procedures (needs mysql 5 or higher)

mysqli_pconnect: DOES NOT EXIST. There is no built in connection function both handling stored procedures and pooling

My advice (via experience and surfing):

If you need stored procedures, omit pooling and use mysqli_connect

If you do not need stored procedures, use mysql_pconnect

daghan
A: 

Not exactly an answer but i think you might also consider PHP Data Objects (PDO) http://php.net/manual/en/book.pdo.php And PDO for MySQL http://php.net/manual/en/ref.pdo-mysql.php

aviv
A: 

This is an old question, but I wanted to add my two cents, as I was looking at this same issue. As of PHP 5.3, mysqli supports persistent connections, you just need to prepend p: to the front of the host name.

If you are running Apache, have you tried looking into connection pooling with mysql through the Apache mod_dbd module? It supports connection pooling for MySQL. http://httpd.apache.org/docs/2.2/mod/mod_dbd.html

snoopaloop