PDO Question
Posted: Mon Jul 03, 2006 4:51 am
Can you use prepared statements in transactions? For example, is this valid when using PDO:
In the manual they only have transaction examples without prepared statements.
Code: Select all
$pdo = new PDO(...);
$sql1 = "INSERT INTO Table1 ...";
$sql2 = "INSERT INTO Table2 ...";
$pdo->beginTransaction();
$statement1 = $pdo->prepare($sql1);
$statement2 = $pdo->prepare($sql2);
$statement1->execute(array(...));
$statement2->execute(array(...));
$pdo->commit();