When should I use closeCursor() for PDO statements?(什么时候应该对 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()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:什么时候应该对 PDO 语句使用 closeCursor()?
基础教程推荐
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- 如何替换eregi() 2022-01-01
