I've tried restoring connections in $_SESSION,
but can only reuse for one user.
Any better solutions?
I've tried restoring connections in $_SESSION,
but can only reuse for one user.
Any better solutions?
What do you mean be "reuse connections"? A connection is a socket being opened to the server..of course you can't store it in $_SESSION. It still would have to reconnect, so it would be pointless anyways. The closest you can come to it is persistent connections.
Read about mysql_pconnect()
.
Unfortunately, persistent connection is not stable in PDO and not supported by MySQLi.
Persistent connections save time when the database server is not in the localhost, but if it is, use of persistent connections is practically irrelevant.