Why is rollback not rolled back after the save () operation?

Source: Internet
Author: User
{Code...} the code above is not rolled back as expected. The data is inserted into the database. The native SQL is executed as follows, which is consistent with expectation! : {Code...} Does it mean I was wrong for 10 thousand years...
DB: beginTransaction (); $ model = new UserWechat (); $ model-> unionid = 'od13wwfnk64bq9me95s-bzuU7j8A '; $ model-> save (); DB :: rollback ();

The code above is not rolled back as expected and the data is inserted into the database.
Run the following native SQL statement as expected! :

Start transaction; insert into user_wechat (unionid) values ('od13wwfnk64bq9me95s-bzuU7j8A '); rollback;

Why am I wrong for 10 thousand years...

Reply content:
DB: beginTransaction (); $ model = new UserWechat (); $ model-> unionid = 'od13wwfnk64bq9me95s-bzuU7j8A '; $ model-> save (); DB :: rollback ();

The code above is not rolled back as expected and the data is inserted into the database.
Run the following native SQL statement as expected! :

Start transaction; insert into user_wechat (unionid) values ('od13wwfnk64bq9me95s-bzuU7j8A '); rollback;

Why am I wrong for 10 thousand years...

Is your database engine InnoDB? Transactions are supported only by InnoDB, and MyISAM does not!

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.