Mysql transactions within transactions

前端 未结 7 1714
清酒与你
清酒与你 2020-12-04 16:33

In a PHP script working with a mysql database, I recently had the need to use a transaction at a point that happened to be inside another transaction. All my tests seem to

7条回答
  •  时光取名叫无心
    2020-12-04 16:52

    This page of the manual might interest you : 12.3.3. Statements That Cause an Implicit Commit; quoting a few sentences :

    The statements listed in this section (and any synonyms for them) implicitly end a transaction, as if you had done a COMMIT before executing the statement.

    And, a bit farther in the page :

    Transaction-control and locking statements. BEGIN, LOCK TABLES, SET autocommit = 1 (if the value is not already 1), START TRANSACTION, UNLOCK TABLES.

    See also this paragraph :

    Transactions cannot be nested.
    This is a consequence of the implicit commit performed for any current transaction when you issue a START TRANSACTION statement or one of its synonyms.

提交回复
热议问题