有没有用PDO关闭mysql准备好的语句的功能? [英] Is there a function for closing a mysql prepared statement with PDO?

查看:62
本文介绍了有没有用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();

这篇关于有没有用PDO关闭mysql准备好的语句的功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆