How can we use these three items together?

Source: Internet
Author: User
How can we use these three items together? $ _ mysqli-> rollback ();
$ _ Mysql-> atuocommit ();
And how to use InnoDB


Reply to discussion (solution)

Http://php.net/manual/zh/mysqli.autocommit.php usage manual

A small example

$ Mysqli = new mysqli ("localhost", "root", "123456", "test"); if ($ mysqli-> connect_error) {die ($ mysql-> connect_error);} // Set the submission to false (rollback is not allowed once submitted) $ mysqli-> autocommit (false); // Save the vertex, save the current record $ sql1 = "update account set balance = balance-1 where id = 1"; $ sql2 = "update account set balance = balance + 1 where id = 2 "; $ b1 = $ mysqli-> query ($ sql1); $ b2 = $ mysqli-> query ($ sql2); if (! $ B1 |! $ B2) {// roll back $ mysqli-> rollback (); echo "failed --". $ mysqli-> error;} else {// submit $ mysqli-> commit (); echo "successful" ;}$ mysqli-> close ();

Http://php.net/manual/zh/mysqli.autocommit.php usage manual


Reading the manual and using kindness are two actions and logic. seeing that you are not necessarily good, good is a result, not a casual one. thinking of goodness is not necessarily good, but you can view it immediately. Because it is a behavior

A small example

$ Mysqli = new mysqli ("localhost", "root", "123456", "test"); if ($ mysqli-> connect_error) {die ($ mysql-> connect_error);} // Set the submission to false (rollback is not allowed once submitted) $ mysqli-> autocommit (false); // Save the vertex, save the current record $ sql1 = "update account set balance = balance-1 where id = 1"; $ sql2 = "update account set balance = balance + 1 where id = 2 "; $ b1 = $ mysqli-> query ($ sql1); $ b2 = $ mysqli-> query ($ sql2); if (! $ B1 |! $ B2) {// roll back $ mysqli-> rollback (); echo "failed --". $ mysqli-> error;} else {// submit $ mysqli-> commit (); echo "successful" ;}$ mysqli-> close ();


The structure is clear.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.