From 63319dea7dd00512d8c0e624d8592b377c176de2 Mon Sep 17 00:00:00 2001 From: Christoph Michael Becker Date: Sun, 8 Nov 2020 12:05:52 +0000 Subject: [PATCH] Update mysqli api support for transactions * MySQL calls it autocommit mode: https://dev.mysql.com/doc/refman/8.0/en/innodb-autocommit-commit-rollback.html * Fix examples. Enable error reporting and remove closing tag * Fixed the two broken links and added mysqli::begin_transaction Patch contributed by Dharman . git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@351328 c90b9560-bf6c-de11-be94-00142212c4b1 --- reference/mysqli/quickstart.xml | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/reference/mysqli/quickstart.xml b/reference/mysqli/quickstart.xml index acd9cf603b..729c07dfc5 100644 --- a/reference/mysqli/quickstart.xml +++ b/reference/mysqli/quickstart.xml @@ -1612,27 +1612,22 @@ to use near 'DROP TABLE mysql.user' at line 1 Transactions can either be controlled using SQL or API calls. It is recommended to use API calls for enabling and disabling the - auto commit mode and for committing and rolling back transactions. + autocommit mode and for committing and rolling back transactions. - Setting auto commit mode with SQL and through the API + Setting <literal>autocommit</literal> mode with SQL and through the API connect_errno) { - echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error; -} /* Recommended: using API to control transactional settings */ $mysqli->autocommit(false); /* Won't be monitored and recognized by the replication and the load balancing plugin */ -if (!$mysqli->query('SET AUTOCOMMIT = 0')) { - echo "Query failed: (" . $mysqli->errno . ") " . $mysqli->error; -} -?> +$mysqli->query('SET AUTOCOMMIT = 0'); ]]> @@ -1642,7 +1637,7 @@ if (!$mysqli->query('SET AUTOCOMMIT = 0')) { can easily monitor API calls. The replication plugin offers transaction aware load balancing, if transactions are controlled with API calls. Transaction aware load balancing is not available if SQL statements are - used for setting auto commit mode, committing or rolling back a transaction. + used for setting autocommit mode, committing or rolling back a transaction. @@ -1650,6 +1645,7 @@ if (!$mysqli->query('SET AUTOCOMMIT = 0')) { autocommit(false); @@ -1658,7 +1654,6 @@ $mysqli->rollback(); $mysqli->query("INSERT INTO test(id) VALUES (2)"); $mysqli->commit(); -?> ]]> @@ -1673,8 +1668,9 @@ $mysqli->commit(); mysqli::autocommit - mysqli_result::commit - mysqli_result::rollback + mysqli::begin_transaction + mysqli::commit + mysqli::rollback