-
-
Save codeforfun-jp/a7ab9aab5fba71bf1eb325cb8fc5d467 to your computer and use it in GitHub Desktop.
【PHP】How to use transaction 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* データベース接続のコードは省略 */ | |
try { | |
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | |
$pdo->beginTransaction(); | |
// ここでデータの保存などの処理を行います。 | |
$pdo->commit(); | |
} catch (Exception $e) { | |
$pdo->rollBack(); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment