Transactions not rolling back?
l0gicnz opened this issue · 2 comments
l0gicnz commented
Hello, I have the following basic code:
// START TRANSACTION
$db->beginTransaction();
$commit = true;
// INSERT TABLE 1 DATA
try {
$db->insert(
'table_1',
[
'param_1' => $param_1,
'param_2' => $param_2
]
);
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
$commit = false;
}
// INSERT TABLE 2 DATA
try {
$db->insert(
'table_2',
[
'param_1' => $param_1,
'param_2' => $param_2
]
);
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
$commit = false;
}
if($commit == true) {
echo "Commit!";
$db->commit();
} else {
echo "Roll Back!";
$db->rollBack();
}
However when either of those exceptions are met and $commit starts being true. The $db-rollBack() does not roll back. Am I doing something wrong?
Driver: MySQL
ServerVersion: 10.2.34-MariaDB
ClientVersion: mysqlnd 8.0.27
ocram commented
Thank you!
You probably meant “starts being false” instead of “starts being true”, right?
What storage engine do your tables use?
Can you check the MySQL error logs?
l0gicnz commented
Thank you!
You probably meant “starts being false” instead of “starts being true”, right?
What storage engine do your tables use?
Can you check the MySQL error logs?
Ohhh, I'm using MyIsam.. I should be using InnoDB.