Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我使用此代码,例如:
$result = $link->prepare("SELECT * FROM animals WHERE id = '$id'"); $result->execute(); $row = $result->fetch(PDO::FETCH_ASSOC); $result = null; $link = null;
可以使用“$result = null;” 关闭这个连接?
它不会关闭数据库连接。但是它会关闭PDOStatement $result,这可能是您所关心的。
PDOStatement $result
如果您想关闭与所有相关资源的连接,您可以使用
$link = null;
你也有。所以我在这里根本看不到任何问题。我什至必须承认,我有点想知道是什么让你这么问。