如果 php 出现错误(try/catch),我应该管理表解锁吗?或者锁在脚本结束时由 PDO 对象自动释放?
最佳答案
是的。除非您使用的是持久连接,否则在脚本终止时,PDO 将关闭连接,而 mysql 将释放所有锁:
PHP will automatically close the connection when your script ends.
http://php.net/manual/en/pdo.connections.phpIf 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/