Re: [PDO] Question on Persistent PDO Connections

From: Date: Fri, 06 Nov 2009 13:30:07 +0000
Subject: Re: [PDO] Question on Persistent PDO Connections
References: 1 2 3 4 5 6 7 8 9 10  Groups: php.pdo 
Request: Send a blank email to pdo+get-315@lists.php.net to get a copy of this message
Lester Caine schrieb:
Ulf Wendel wrote:
Lester Caine schrieb:
Ulf Wendel wrote:
Lukas Kahwe Smith schrieb:
well for mysql traditonally persistent connections came with the risk of an unclean session. i guess there is now a solution to clean up the session fairly well, making persistent connections more feasible,
COM_CHANGE_USER/mysql_change_user() cleans up the line. The call itself exists since quite some time. In its early days (say more than three years ago) it was known to have issues. But its working fine nowadays. Its possible to clean up the line before reuse, if wanted. Calling mysql_change_user is the default for ext/mysqli. However, if you know what you do, you may not want to clean the line for performance reasons.
Actually Ulf that sounds a little strange when the mechanism to use an existing connection is that your new connection MUST have the same username and password. Ideally I think, there should be nothing
Not sure if I get what you say. mysql_change_user() (C API [1], protocol command COM_CHANGE_USER) is the MySQL way of resetting an existing connection. After the call the connection is as if its new. As server permissions can change between putting a connection into a persistent pool and reusing a connection, it is necessary to re-authenticate the user.
We are currently discussing persistent connctions http://de.php.net/manual/en/function.mysql-pconnect.php in the case of MySQL and using pconnect re-uses a previous connection if the username and password are the same. Actually when I look at mysql_change_user() http://de.php.net/manual/en/function.mysql-change-user.php it says it deprecated.
And I am talking about persistent connections in general and what can or cannot be done with PDO and MySQL. I don't care the about ext/mysql interface at this point :-)
In any case, pconnect would only fail if the user's credentials had changed which would be the same as for a simple 'connect'
Well, from an implementors perspective reusing a persistent connection can fail if the line/pipe is gone and/or if credentials changed. In that case a driver can create a new connection. From a user perspective those things can happen transparently. Ulf

« previous php.pdo (#315) next »