Php: whether the transaction is successful

Source: Internet
Author: User
Ezqlphp newbie transaction how to capture operation database errors multiple statements operation database all successful execution before committing the transaction otherwise rollback for example insert a successful execution update statement execution no error, but the update affects the record to 0. do not roll back the following records. $ uname is the same as the uname value in the database $ res, and 0 transaction failures will be returned $ db-& gt; query (& quot; BEGIN & quot;); $ SQL & quot; updatemembersetuname $ unamewhereid $ id & quot; $ res $ db php transaction

New to ezql php
An error occurred while capturing and operating the database for transactions.
Transactions are committed only when multiple statements are successfully executed in the database. Otherwise, the transaction is rolled back.
For example, the insert statement is successfully executed.
The update statement is executed correctly, but the update affects 0 records. do not roll back at this time.

As shown below, the $ uname value is the same as the uname value in the database
$ Res returns 0 transaction failures

$ Db-> query ("BEGIN"); $ SQL = "update member set uname = $ uname where id = $ id "; $ res = $ db-> query ($ SQL); if ($ res) {$ db-> query ("COMMIT"); errAlert ("successful", "list. php ");} else {$ db-> query (" ROLLBACK "); errAlert (" failed, error ", $ theUrl );} $ db-> query ("END ");

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.