should I commit in the following code?

丶灬走出姿态 提交于 2019-12-04 21:39:01
  • Since you aren't modifying the database at all, you don't need to enable transactions, so don't set AutoCommit to zero. That way there's no need to call commit anywhere either, and the database will be disconnected automatically when the handle goes out of dcope

  • Since you're handling errors yourself you shouldn't set RaiseError to 1. That will cause your program to die immediately if any error occurs and your own handling code won't get executed

  • There's no need to call finish. It won't do any harm here, but it's also pointless and should almost never be necessary

The warning means that there are uncommitted transactions?

There is an uncommitted transaction since you requested for transactions to be used, but the warning actually notifies you that a rollback was performed implicitly. It tells you this because this may result in a loss of information. Obviously, it won't result in a loss of information in this case, but the check isn't smart enough of realize this.

What I am missing?

$hfpDbh->disconnect(); or $hfpDbh->rollback();

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!