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 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)