0
トランザクション内で複数のクエリを実行し、個別に出力を処理できますか?私はmysql、mysqlpdo、phpを使用しています。たとえば、トランザクション内で複数のクエリを実行し、別々に出力を処理する
try {
$dbh->beginTransaction();
// A set of queries; if one fails, an exception should be thrown
$stmt1 = $dbh->prepare('first query');
$stmt2 = $dbh->prepare('second query');
$stmt3 = $dbh->prepare('third query');
if ($stmt1->execute() && $stmt2->execute() && $stmt3->execute())
{
$dbh->commit();
}
} catch(Exception $e) {
$dbh->rollback();
}
// output data of each row
while ($rows = $stmt1->fetch(PDO::FETCH_ASSOC)) { ... }
// output data of each row
while ($rows = $stmt2->fetch(PDO::FETCH_ASSOC)) { ... }
// output data of each row
while ($rows = $stmt3->fetch(PDO::FETCH_ASSOC)) { ... }
クエリでは、異なる出力が生成され、異なる出力が使用されます。