From: andy-lists on

>
> As long as you test it (hopefully using some sort of automated tests) you should be right.
>
> Since you're using persistent connections (make sure you set pdo to do the same), I don't think you're really doubling the number of connections.

Yeah, I think PDO uses the underlying mysql/pgsql functions anyway - it just provides a common API layer across all database types.

Therefore if you call mysql_pconnect outside of PDO, then call the same database server with PDO, technically it should realise the connection has already been made to that server and use your previous connection.

As Chris pointed out, make sure PDO will also use persistent connections.

Regards,
Andy


From: andy-lists on

>
> One thing to be careful is if you are relying on 'transactions' to handle anything. Obviously the transaction has to be in the same connection just to work. Despite what others have said, the PDO connection will be different to the generic mysql connection as it is a separate process. Persistent connections will only reuse an already open connection, you can't connect two processes to the same connection. You would not know which process was accessing things.

According to the documentation:

"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."

Therefore, providing you've configured PHP's --with-mysql and --with-pdo-mysql options with the same MySQL library, then as long as the host, username and password are the same, the same connection will be re-used for both the native (mysql_pconnect) connection and the PDO connection.

I'm not sure about the mysqli library, but I believe that lies beneath the mysql_* family of functions anyway so it shouldn't make a difference whether you're using libmysqlclient or mysqli.

Regards,
Andy