如何从客户端杀死php连接?

时间:2021-07-12 02:32:43

I am using jquery with php.

我正在使用jquery与PHP。

On the client side the user can close the dialogbox or it will stop ajax request due to the time-out limit.

在客户端,用户可以关闭对话框,或者由于超时限制而停止ajax请求。

The problem is the mysql is still continue the process which is in the "sending data state". But the php process no longer available because of:

问题是mysql仍在继续处于“发送数据状态”的过程。但由于以下原因,php进程不再可用:

set_time_limit(20);

Are there way to kill the PHP::PDO connection with mysql process?

有没有办法用mysql进程杀死PHP :: PDO连接?

Thanks Arman.

1 个解决方案

#1


2  

Sounds like you're using persistent database connections. With those, the connection from mysql<->php is kept alive regardless of whether a client is actually connected or not. This allows queries to keep running and keeps any variables, locks, temporary tables, etc... to stay alive and gum up the works.

听起来像是在使用持久数据库连接。有了这些,无论客户端是否实际连接,来自mysql < - > php的连接都会保持活动状态。这允许查询继续运行并保留任何变量,锁,临时表等......以保持活力并使工作失效。

Disable persistent connections, and your 'stuck' queries will die when the client disconnects and PHP cleans up afterwards.

禁用持久连接,当客户端断开连接并且PHP随后清理时,您的“卡住”查询将会死亡。

#1


2  

Sounds like you're using persistent database connections. With those, the connection from mysql<->php is kept alive regardless of whether a client is actually connected or not. This allows queries to keep running and keeps any variables, locks, temporary tables, etc... to stay alive and gum up the works.

听起来像是在使用持久数据库连接。有了这些,无论客户端是否实际连接,来自mysql < - > php的连接都会保持活动状态。这允许查询继续运行并保留任何变量,锁,临时表等......以保持活力并使工作失效。

Disable persistent connections, and your 'stuck' queries will die when the client disconnects and PHP cleans up afterwards.

禁用持久连接,当客户端断开连接并且PHP随后清理时,您的“卡住”查询将会死亡。