Here is a transaction structure:
try {
$dbh_con->beginTransaction();
// queries here
$dbh_con->commit();
} catch(PDOException $e) {
$dbh_con->rollBack();
}
Now I want to know can I use header('Location: ../);
in the transaction? So what happens?
Here is 3 cases:
try {
$dbh_con->beginTransaction();
header('Location: ../mypage.php1'); // (1)
// queries here
$dbh_con->commit();
header('Location: ../mypage.php2'); // (2)
} catch(PDOException $e) {
header('Location: ../mypage.php3'); // (3)
$dbh_con->rollBack();
}
Ok using a redirect code in where of (1)
, (2)
and (3)
is standard? And what happens with the queries in that case?
Based on the tests, when I redirect a script before commit()
(even after queries), none of those queries never work. I mean nothing changes.