PHP Mysql PDO和解锁表

标签 php mysql pdo table-locking

如果 php 出现错误(try/catch),我应该管理表解锁吗?或者锁在脚本结束时由 PDO 对象自动释放?

最佳答案

是的。除非您使用的是持久连接,否则在脚本终止时,PDO 将关闭连接,而 mysql 将释放所有锁:

PHP will automatically close the connection when your script ends.
http://php.net/manual/en/pdo.connections.php

If the connection for a client session terminates, whether normally or abnormally, the server implicitly releases all table locks held by the session (transactional and nontransactional).
https://dev.mysql.com/doc/refman/5.1/en/lock-tables.html

关于PHP Mysql PDO和解锁表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33164529/

相关文章:

php - 此网页有一个重定向循环 - PHP 登录

java - 如何在 Hibernate 中插入外键定义为 Long 的实体?

php - 根据 mysql 的输入填充表

php - 函数参数 php 不工作

php - 选择要进行 sql 和 Sum 的日期

php - 查询2表连接

php - 将图像从 mysql blob 数据库添加到 ZipArchive

php - PDO 准备语句 - NULL

php - 如何在 propel 查询中添加别名

mysql - 存储一个SQL字符串数组,后续查询