Created
June 4, 2012 01:18
-
-
Save albertein/2865748 to your computer and use it in GitHub Desktop.
PDO transactions + prepared statemes
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
$dbh->beginTransaction(); | |
$statement = $dbh->prepare("INSERT INTO TABLE (field1, field2) VALUES (:v1, :v2)"); | |
$stmt->bindParam(':v1', $value1); | |
$stmt->bindParam(':v2', $value2); | |
for ($i = 0; $i < 300; $i++) { | |
$value1 = 'value'; | |
$value2 = 'another value'; | |
$stmt->execute(); | |
} | |
$dbh->commit(); | |
//On error should call $dbh->rollback(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment