What I would like to know is the underlying connection behaviour of a PDO. I will start with the problem. At work we are having a lot of CONNECTED connections to our MySQL database now I thought as long as the PDO object was destroyed(unset or set to null) the connection was closed but these connection seem to stay open. In the MySQL "show full processlist" there seem to be over 100 connections that are "Command" sleep. I'm trying to work out if this is because of the "interactive_timeout" default setting being 28800(not sure if thats seconds or miliseconds) http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html#sysvar_interactive_timeout or if there is something I can do to with PDO like pass the object around in a session instead of calling the same instance stored in a variable in an included file.
Any help will be greatly appreciated.
There is absolutely nothing special with PDO connections. It's just a regular socket connection, Opened with script start and closed at end.
The issue you are experiencing at work is probably caused by the persistent connect frature, which is not however specific for PDO, but available for all the drivers via mysql API. Its the only purpose to keep the connection opened, regardless of the lifetime of the script. However, one have not to be mistaken on the nature of the feature: from the script point of view it's always brand new connection.