开发者

Unexpected MySQL Transaction Commit

I have a PHP script that works with both a MySQL database and an ODBC DB connection (QODBC into QuickBooks). The setup is like this:

Retrieve rows from MySQL database
Begin MySQL transaction:
    Loop through rows
    Process data
    MySQL Insert/Update
    MySQL Update
    QODBC Selects/Inserts
End Loop
    MySQL Delete
Commit Transaction

The problem is, if there is an error in the QODBC section, the MySQL commands up to that point will be committed. This is leading to duplicate and wrong data in MySQL. There are no nested transactions and all the queries success/failure is being add开发者_运维问答ressed (ie no fatal errors or premature exiting of a script).

The question is - is there a problem when connecting to two different databases via PHP, in the same script? What seems to be happening is when the script gets to the ODBC section, the MySQL transaction is closed and auto-committed.


I'd say there are two potential reasons:

  • Your tables were created using MyISAM which does not support transactions
  • Your connection is set to autocommit
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜