dpda53918 2014-05-30 14:17
浏览 43

PDO连接行为

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.

  • 写回答

1条回答 默认 最新

  • duanhuizhe6767 2014-05-30 14:38
    关注

    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.

    评论

报告相同问题?

悬赏问题

  • ¥15 一道python难题
  • ¥15 用matlab 设计一个不动点迭代法求解非线性方程组的代码
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度