PHP, MySQL, PDO Transactions - Does the code inside try block stop at commit()?

前端 未结 3 1444
一生所求
一生所求 2021-01-23 08:02

I\'m pretty new to transactions.

Before, what I was doing was something like:

Code Block 1

$db = new PDO(...);

$stmt = $db->prepare(         


        
3条回答
  •  失恋的感觉
    2021-01-23 08:40

    if you face any error you can do this to rollback all transactions like this

    catch(Exception $e){
        $db->rollBack();
        // Failed, maybe write the error to a txt file or something
        return false;
    }
    

提交回复
热议问题