且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

PHP mysqli :: autocommit VS“START TRANSACTION”

更新时间:2022-02-13 22:44:06

是数据访问包装器需要知道事务何时开始/结束的原因。例如,在我的头顶部,连接池方案必须知道在事务中间什么时候完成了先前使用的连接,并且不返回到连接池以便在这种情况下重新使用。

It's possible there might be reasons why a data access wrapper would need to know when a transaction was started/ended. For example off the top of my head, a connection-pooling scheme would have to know when a previously-used connection was finished with in the middle of a transaction, and not return it to the connection pool for re-use in that case.

我不知道 mysqli 中的任何问题,这将要求您使用本机方法, SQL版本,但它可能在一般情况下...这就是为什么它只有有时应该。在任何情况下,PHP方法比SQL字符串版本更容易阅读,所以我会说,无论如何。

I'm not aware of any issues in mysqli that would require you to use the native method rather than the SQL version, but it's possibly in the general case... that's why it's only "sometimes should". In any case, the PHP method is easier to read than the SQL-string version, so I'd say go with that anyway.