简体   繁体   中英

mysqli_multi_query and mysql transactions

I'm experimenting with transactions for the first time in mySQL.

I am wondering if it is safe to use mysqli_multi_query for this purpose. That is, can I assume that if any of the SQL statements fails, everything will be rolled back?

    $query = "
        START TRANSACTION;
        (a bunch of SQL statements)
        COMMIT;
    ";

    if (mysqli_multi_query($connection, $query)) {
        do {
            if ($result = mysqli_store_result($connection)) mysqli_free_result($result);
        } while (mysqli_next_result($connection));
    }

Thanks,

是的,mysqli_multi_query使用InnoDB处理MySQL事务。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM