問題描述
關于 closeCursor()
的 PHP 文檔說它
The PHP documentation on closeCursor()
says that it
釋放與服務器的連接,以便可以發(fā)出其他 SQL 語句,但使該語句處于可以再次執(zhí)行的狀態(tài).
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.
將它用于不返回數(shù)據(jù)的數(shù)據(jù)庫調(diào)用與返回數(shù)據(jù)的數(shù)據(jù)庫調(diào)用是否不同?
Is it different to use it for database calls that don't return data vs. those that do?
推薦答案
這取決于所使用的驅(qū)動程序.我認為對于 mysql,這只會清除語句的結(jié)果.調(diào)用 closeCursor() 后,您不能再調(diào)用 fetch().但是,再次執(zhí)行該語句應該不是問題.嘗試查看 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()?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!