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 Pwm双极模式H桥驱动控制电机
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题