mysql.begin

mysql.begin

mysql.begin

Function

Opens a MySQL transaction and returns the MysqlTransaction transaction handle.

Syntax

Parameters

No parameters. DSN provided by mysql(dsn).

Return value

TypeDescription
MysqlTransactionTransaction handle. Query, bind, all, one, exec, commit, rollback, close and status can continue to be called within the transaction.

Code Example

Notes

  • begin will exclusively occupy a connection, do not hold it for a long time until the transaction ends.
  • Commit, rollback, or close must be explicitly called after the transaction is completed.
  • begin, intra-transaction SQL and commit/rollback/close are all subject to BT_MYSQL_QUERY_TIMEOUT_MS.
  • When the transaction slow call exceeds BT_MYSQL_SLOW_MS, only the time consumption, method name and binding number are recorded, but the binding value is not recorded.