什么时候应该对 PDO 语句使用 closeCursor()?

When should I use closeCursor() for PDO statements?(什么时候应该对 PDO 语句使用 closeCursor()?)
本文介绍了什么时候应该对 PDO 语句使用 closeCursor()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

关于 closeCursor() 的 PHP 文档说它

The PHP documentation on closeCursor() says that it

释放与服务器的连接,以便可以发出其他 SQL 语句,但使该语句处于可以再次执行的状态.

frees up the connection to the server so that other SQL statements may be issued, but leaves the statement in a state that enables it to be executed again.

当我使用该命令时,它是否存在于我的查询语句之间似乎并不重要,我开始怀疑我是否需要它.

When I have used the command though it doesn't seem to matter if it is there or not in between my query statements, and I am beginning to wonder if I need it at all.

将它用于不返回数据的数据库调用与返回数据的数据库调用是否不同?

Is it different to use it for database calls that don't return data vs. those that do?

推荐答案

这取决于所使用的驱动程序.我认为对于 mysql,这只会清除语句的结果.调用 closeCursor() 后,您不能再调用 fetch().但是,再次执行该语句应该不是问题.尝试查看 mysql_free_result(),它做了类似的事情.

This depends on the driver used. I think for mysql this will do nothing else than clear the result of the statement. After calling closeCursor() you cannot call fetch() anymore. However executing the statement again should not be a problem. Try to look at mysql_free_result(), it does a similar thing.

这篇关于什么时候应该对 PDO 语句使用 closeCursor()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)