什么时候应该对PDO语句使用closeCursor()? [英] When should I use closeCursor() for PDO statements?

查看:117
本文介绍了什么时候应该对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()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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