Home >Backend Development >PHP Tutorial >php 用pdo 连接mysql 服务器后,还需要断开服务器吗?

php 用pdo 连接mysql 服务器后,还需要断开服务器吗?

WBOY
WBOYOriginal
2016-06-06 20:08:44982browse

以前学习用 $mysqli对象链接服务器后,查询完了需要断开服务器
$mysqli->close();

想问问pdo 还需要断开吗?
如果需要,怎么写?

回复内容:

以前学习用 $mysqli对象链接服务器后,查询完了需要断开服务器
$mysqli->close();

想问问pdo 还需要断开吗?
如果需要,怎么写?

php自带GC(垃圾回收机制)机制,自动释放内存

<code>$pdo = new \PDO($dsn, $username, $pwd);
$pdo = null;

</code>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn