PDO bug: prepare() with multi-queries doesn't work inside a transaction

瘦欲@ 提交于 2019-12-24 08:36:22

问题


Searching for the solution to my previous question I've come across a weird fact - PDO prepare() with multi-queries does not work correctly inside a transaction. You get no warning, no exception, nothing - just silence and no commit/rollback.

Furthermore, you get no exception even if some of the queries except for the first one contain errors. Although if the first query contains an error you get an exception as expected.

If there is no transaction everything works fine.

If you put several prepare() statements (with a single query each one) inside a single transaction - again, everything works correctly.

I've read that MySQL does not support prepared statements with multi-queries, but the thing is that PDO by default does not deal with real MySQL prepared statements and only emulates them.

I've spent the whole day trying to find some document describing this problem but I failed.

Does anybody know if it's really a PDO bug?


回答1:


This behavior actually is a bug on some versions (tested on PHP 5.4.6-Ubuntu and PHP 5.4.19-Windows).

There's no (easy to find) documentation about this problem, an the only workaround is to use multiple prepared statements.

Just reported the bug https://bugs.php.net/bug.php?id=65994



来源:https://stackoverflow.com/questions/9614876/pdo-bug-prepare-with-multi-queries-doesnt-work-inside-a-transaction

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