有没有用PDO关闭mysql准备好的语句的功能?

问题描述:

在mysqli准备好的语句中,有 mysqli_stmt::close() (关闭准备好的语句):

In mysqli prepared statements there ismysqli_stmt::close() (Closes a prepared statement):

$stmt->close();

我已经搜索了php.net和网络,但找不到PDO的替代方案.

I have searched php.net and the web and cannot find an alternative for PDO.

这可能吗?

在每个脚本结尾处使用它有什么好处?

And what are the benefits of using it at the end of each of your scripts?

我知道,

$connection = null;

关闭与mysql的连接,但是关闭查询怎么办?

closes the connection to mysql, but what about closing the query?

要释放结果集,您可以应用基本的PHP方式.

To free the result set you can apply basic PHP way.

如果使用 PDOStatement::fetchAll() 返回结果,则需要unset()变量清除它:

If you are returning the results with PDOStatement::fetchAll() then you would need to unset() the variable to clear it:

$variable = $stmt->fetchAll();

unset($variable);
// or:
$variable = null; 

PDOStatement::closeCursor() (关闭游标,使语句可以再次执行. )可能会有所帮助:

Or PDOStatement::closeCursor() (Closes the cursor, enabling the statement to be executed again.) may be helpful:

$success = $stmt->closeCursor();