问题描述
关于 closeCursor()
的 PHP 文档说它
The PHP documentation on closeCursor()
says that it
释放与服务器的连接,以便可以发出其他 SQL 语句,但使该语句处于可以再次执行的状态.
当我使用该命令时,它是否存在于我的查询语句之间似乎并不重要,我开始怀疑我是否需要它.
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()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!