开发者

mysqli_multi_query and mysql transactions

开发者 https://www.devze.com 2023-01-01 19:06 出处:网络
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

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 b开发者_运维问答unch 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,


Yes, mysqli_multi_query handles MySQL Transaction using InnoDB's.

0

精彩评论

暂无评论...
验证码 换一张
取 消