📜  pdo 事务 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:27.277000             🧑  作者: Mango

代码示例1
beginTransaction();

try    {
    /* Change the database schema and data */
    $sth = $dbh->exec("DROP TABLE fruit");
    $sth = $dbh->exec("UPDATE dessert
        SET name = 'hamburger'");
}
catch(Exception $e){
  /* Recognize mistake and roll back changes */
  $dbh->rollBack();
}
/* Commit changes */
$dbh->commit();